我是VBA的初學者,我只想突出顯示N和AA列中的空單元格。在一個For循環中可以有多個範圍來代替下面的代碼來完成這個工作?在一個VBA For循環中有多個範圍?
Private Sub CommandButton22_Click()
'HIGHLIGHT
Dim cell As Range
For Each cell In Range("N")
If cell.Value = vbNullString Then
cell.Interior.ColorIndex = 6
End If
Next cell
For Each cell In Range("AA")
If cell.Value = vbNullString Then
cell.Interior.ColorIndex = 6
End If
Next cell
End Sub
比你呢!它像夢一樣工作。 UsedRange還修復了我的空單元格不在數據範圍問題內。我非常感謝你的幫助! –
感謝您接受我的回答。快樂編碼:) – 2016-10-03 12:42:30