[英]Looping a VBA statement to check for empty cells before continuing sub
我是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
要突出显示为空的单元格,请使用条件格式(可以不使用代码而应用)
请参阅Debra Dalgleish的网站
代码问题
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.