Excel_VBA 常用代码

时间:2019-06-15 18:21:56   收藏:0   阅读:76

单元格编辑后改变背景色(6号,355832828)

 1 Dim oldvalue As Variant
 2 
 3 Private Sub Worksheet_Change(ByVal Target As Range)
 4     On Error Resume Next
 5     If oldvalue <> Target.Value Then
 6         With Target.Cells.FormatConditions
 7             .Delete
 8             .Add xlExpression, , "TRUE"
 9             .Item(1).Interior.ColorIndex = 9
10         End With
11     End If
12 End Sub
13 
14 Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
15     oldvalue = Target.Value
16 End Sub

 

原文:https://www.cnblogs.com/yzhyingcool/p/11028406.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!