【问题标题】:Looping a VBA statement to check for empty cells before continuing sub在继续 sub 之前循环 VBA 语句以检查空单元格
【发布时间】:2015-01-19 10:39:01
【问题描述】:

我是 VBA 新手。我将如何更改以下代码以检查单元格 Q1:Q5 而不仅仅是 Q1。另外,是否可以暂时突出显示空白的单元格?

If ActiveSheet.Range("Q1").Value = "" Then
    Answer = MsgBox("You have not entered all of the required details.", vbCritical, "Error")
Exit Sub
End If

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    为了突出显示为空的单元格,请使用条件格式(无需代码即可应用)

    查看 Debra Dalgleish 的site

    代码问题

    Sub CellCheck()
    Dim rng1 As Range
    Set rng1 = Range("Q1:Q5")
    If Application.CountA(rng1) <> rng1.Cells.Count Then _
        Answer = MsgBox("You have not entered all of the required details.", vbCritical, "Error")
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-03
      • 1970-01-01
      • 2013-04-25
      • 1970-01-01
      • 2020-04-01
      • 1970-01-01
      • 2015-03-25
      • 2021-03-23
      相关资源
      最近更新 更多