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

猜你喜欢

转载自www.cnblogs.com/yzhyingcool/p/11028406.html
今日推荐