Article ID: 139573
Article Last Modified on 10/11/2006
Sub CountBlanks()
' Dimension the variables used in the example
Dim Holder As Object
Dim Answer As Integer
' Creates the object called holder that is equal to the range
' that is selected from the input box.
Set Holder = _
Application.InputBox("Input range to check for blanks", _
"Blank Cell Counter", Type:=8)
' Set the counter to 0.
Answer = 0
' Count each blank cell.
For Each x In Holder
If IsEmpty(x.Value) Then Answer = Answer + 1
Next x
' Displays answer in a message box.
MsgBox "There are " & Answer & " blank cells in this range."
End Sub
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: 8.00 XL97 XL98 XL7 XL5 howto XL
Keywords: kbhowto kbualink97 kbprogramming kbdtacode KB139573