我是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