小编D. *_*. R的帖子

一个VBA For循环中的多个范围?

我是VBA的初学者,我只想突出N列和AA列中的空单元格.可以在一个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
Run Code Online (Sandbox Code Playgroud)

excel vba for-loop excel-vba

3
推荐指数
2
解决办法
8247
查看次数

标签 统计

excel ×1

excel-vba ×1

for-loop ×1

vba ×1