Forum Discussion
Kenneth Rothschild
May 19, 2021Copper Contributor
@COUNTBLANK
The @countblank function is not helping me 😞 Some of the cells are actually merged cells...' For example, some cells are only one cell long, and other cells are merged - spanning 5 cells. ...
- May 19, 2021I don't understand why it worked for you.. but here is what I have encountered (an example)
B2 4-May
B3 5/3/2021
B4
B5
B6 4-May
B7
B8 5-May
B9 6-May
B10 7-May
B11
B12
B13 8-May
B14 9-May
B15
B16
B17
B18 10-May
9 "=COUNT(B2:B18)"
HansVogelaar
May 19, 2021MVP
You have found one of the many, many reasons why using merged cells is a bad idea...
If I interpret your question correctly, you'd need a custom function. The following is based on an idea of Harlan Grove:
Function RealBlank(rng As Range) As Long
Dim c As Range
Dim skip As Range
Application.Volatile
For Each c In rng
If skip Is Nothing Then
If c.Value = "" Then
RealBlank = RealBlank + 1
End If
If c.MergeCells Then
Set skip = c.MergeArea
End If
ElseIf Intersect(c, skip) Is Nothing Then
If c.Value = "" Then
RealBlank = RealBlank + 1
End If
If c.MergeCells Then
Set skip = Union(skip, c.MergeArea)
End If
End If
Next c
End Function- Kenneth RothschildMay 19, 2021Copper ContributorHans - thank you for the post... I'm not so savvy about doing this... How do I implement this??? Thank you...
- HansVogelaarMay 19, 2021MVP
Press Alt+F11 to activate the Visual Basic Editor.
Select Insert > Module to create a new code module.
Copy the code from my previous reply into the module.
Switch back to Excel.
To count the number of blank cells in A1:D10, counting a blank merged cell as one, use
=RealBlank(A1:D10)
Save the workbook as a macro-enabled workbook (*.xlsm).
Make sure that you allow macros when you open the workbook.
- Kenneth RothschildMay 19, 2021Copper ContributorTHANK YOU!!!
THANK YOU!!!
THANK YOU!!!