I have a data set with a large number of blank fields in each column. I would like to count the number of blank cells in each column after I've applied some arbitrary filters to other column(s).
I've gotten this to work in a sub
with the following
Sub whatever()
Dim myrange As Range
Set myrange = Worksheets("Sheet1").Range("a1:a100")
myrange.SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeBlanks).Count
End Sub
But when I try to put it in a UDF like so
Function CountBlankVisible(myrange As Range)
CountBlankVisible = myrange.SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeBlanks).Count
End Function
It seems to be counting every cell in the range regardless of cell type. Any ideas why this would work in a sub but not as a function? is it possible to get this count some other way?
SpecialCells
method doesn't behave properly in a UDF. – Anthony Bird