Forum Discussion
jukhamil
Sep 17, 2021Brass Contributor
How to count the number of blank cells in a column?
I would like to count the number of blank cells in a column. I am trying to do this via: Set ws = Worksheets("Sheet1") Set col = ws.Columns(1) Application.WorksheetFunction.CountA(col) ...
HansVogelaar
Sep 17, 2021MVP
Do you really want to count the number of blank cells in an entire column? That will probably be very high.
You could try
Application.WorksheetFunction.CountBlank(col)
or
Application.WorksheetFunction.CountIf(col, "")
- jukhamilSep 17, 2021Brass ContributorThanks. Actually I did misspeak there. I would like to count the number of non-empty cells, not the number of empty or blank ones. What I actually would like to do is figure out which columns are completely empty and delete them. I found some examples online suggesting I use if CountA = 0.
If you know a way to count cells that do not have empty strings in them or another way to achieve the above I'd love to hear about it.
Thanks very much.- HansVogelaarSep 17, 2021MVP
- jukhamilSep 20, 2021Brass ContributorThanks. I can't find the official documentation for the "< " expression. Would it be possible for you to link to it? Thanks very much.
- Detlef_LewinSep 17, 2021Silver Contributor