我有一段代码,要在每个工作表中运行,现在我把这段代码写在每个工作表下面都有,这样十分不妥当,有没一种方法,就用一段代码,直接写在模块下,控制多个工作表?
Sub WorkSheet_SelectionChange(ByVal Target As Range)
If Target.Row > 0 Then
On Error Resume Next
[ChangColor_With].FormatConditions.Delete
'整行
Target.EntireRow.Name = "ChangColor_With"
'单元格
'Target.Name = "ChangColor_With"
With [ChangColor_With].FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = 4 '绿色
End With
End If
End Sub