Excel_VBA 常用代码

单元格编辑后改变背景色(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

 

posted @ 2019-06-15 18:08  yzhyingcool  阅读(714)  评论(0编辑  收藏  举报