我已经查看并尝试了所有数组并设置了函数,但是当我在程序中运行它时,它不起作用。 这是我的程序
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Sheets("Check").Range("G16").Value = "Special Request" And _
Range("G17").Value = "" Or _
Range("G18").Value = "" Or _
Range("G19").Value = "" Or _
Range("G20").Value = "" Then
MsgBox "Please verify that all tabs are check using the check tab"
Cancel = True
End If
End Sub
我不想为每个单元格命名,而是要插入范围。一个例子是; G17:G20或 G24:G29或 G33:G38然后_
如果有人有任何建议,将不胜感激
答案 0 :(得分:0)
使用Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Target As Range
Set Target = Range("G17:G20,G33:G38")
If Sheets("Check").Range("G16").Value = "Special Request" And _
WorksheetFunction.CountA(Target) < Target.count Then
MsgBox "Please verify that all tabs are check using the check tab"
Cancel = True
End If
End Sub
计算范围内非空白值的数量,并将其与范围单元格计数进行比较。
reactor-netty