我有一个小宏,可以在根据月份进行编辑时突出显示单元格。我想让这个子程序只发生在 D 列。有没有办法做到这一点?代码如下:
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Month(Date)
Case Is = 1
Range(curCell).Interior.ColorIndex = 20
Case Is = 2
Range(curCell).Interior.ColorIndex = 24
Case Is = 3
Range(curCell).Interior.ColorIndex = 33
Case Is = 4
Range(curCell).Interior.ColorIndex = 18
Case Is = 5
Range(curCell).Interior.ColorIndex = 23
Case Is = 6
Range(curCell).Interior.ColorIndex = 45
Case Is = 7
Range(curCell).Interior.ColorIndex = 22
Case Is = 8
Range(curCell).Interior.ColorIndex = 38
Case Is = 9
Range(curCell).Interior.ColorIndex = 35
Case Is = 10
Range(curCell).Interior.ColorIndex = 31
Case Is = 11
Range(curCell).Interior.ColorIndex = 44
Case Is = 12
Range(curCell).Interior.ColorIndex = 48
End Select
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
curCell = ActiveCell.Address(Columns(0, 0))
End Sub