在选定范围内找不到空白单元格时进一步运行代码



我编写了一个代码,如果所选范围内的任何单元格为空白,则删除行本身,但如果找不到空格,则将其终止。 我想进一步运行代码。这是代码:-

Application.ScreenUpdating = False 
Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Application.ScreenUpdating = True 
'For instance if i want the machine to pop up a msgbox,in case if no blanks found   
Msgbox "Congrats!"

测试具有值的单元格计数是否与区域中的单元格数相同:

Application.ScreenUpdating = False
With ActiveSheet 'Better practice to assign actual sheet.
If Not Application.WorksheetFunction.CountA(.Range("A:A")) = .Range("A:A").Cells.Count Then
.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Else
MsgBox "Congrats!"
End If
End With
Application.ScreenUpdating = True

相关内容

最新更新