count blanks in column with msg box

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello all and good morning

I want to count the number of blank cells in a column range and have a message box provide the answer
this is waht i have tried so far, any help would be great please

Code:
Dim LastRow As Long
Dim iBlank, rng As Range
 
LastRow = Sheets("Data").Range("B2").End(xlDown).Row


    Set rng = Sheets("Data").Range("AA2:AA" & LastRow).Find("")


    With WorksheetFunction
        iBlank = .CountA(rng)
    End With
    MsgBox "Blank: " & iBlank
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Counts cells that are truly empty (ie do not contain a value or a formula)
Code:
Sub EmptyCells()
    Dim LastRow As Long, rng As Range
    With Sheets("Data")
        LastRow = .Range("B" & Rows.Count).End(xlUp).Row
        Set rng = .Range("AA2:AA" & LastRow).SpecialCells(xlCellTypeBlanks)
    End With
    MsgBox "Truly empty: " & rng.Count
End Sub

But if some cells contain empty strings returned by formulas etc, use this
Code:
Sub CountCellsWithNoValue()
    Dim LastRow As Long, rng As Range
    With Sheets("Data")
        LastRow = .Range("B" & Rows.Count).End(xlUp).Row
        Set rng = .Range("AA2:AA" & LastRow)
    End With
    MsgBox "No Value: " & WorksheetFunction.CountIf(rng, "")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,874
Messages
6,122,034
Members
449,061
Latest member
TheRealJoaquin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top