下面的代碼工作,並更改北進入時的偏移單元格,我也想讓它改變,如果它的南,西或東,但我似乎可以找到一種方法來添加此。VBA多個IF值
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("A7:A26")
Set rng = Range("A7:A26")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
For Each cell In rng.Cells
If cell.Value = "North" Then
cell.Offset(0, 1).Interior.Color = RGB(0, 255, 0)
cell.Offset(0, 2).Interior.Color = RGB(0, 255, 0)
cell.Offset(0, 3).Interior.Color = RGB(0, 255, 0)
End If
Next
End If
End Sub
你想對每個方向使用相同的顏色或不同的顏色嗎? –