COUNTBLANK and merged cells

I

igor

I am trying to count blank cells in a spreadsheet, and the COUNTBLANK
function returns merged cells as blank apart from the left-most,
upper-most cell.
Is there a way to count all cells in a merged cell as having content,
and not just the first one, so that they are not counted as blank in
the COUNTBLANK function?
Any help would be very much appreciated.



------------------------------------------------




------------------------------------------------
 
M

Myrna Larson

As others have said on many occasions, merged cells seem to create more problems than they
solve. I think you've just come up with another example.

If you are merging cells to accomplish centering a header over several columns, I suggest you
use the CenterAcrossSelection alignment.

Otherwise, insert blank columns so the long text can spill to the right.
 
H

Harlan Grove

I am trying to count blank cells in a spreadsheet, and the COUNTBLANK
function returns merged cells as blank apart from the left-most,
upper-most cell.
Is there a way to count all cells in a merged cell as having content,
and not just the first one, so that they are not counted as blank in
the COUNTBLANK function?

Not without a UDF (user-defined function).


Function foo(rng As Range) As Long
Dim c As Range, skip As Range

For Each c In rng

If skip Is Nothing Then

If c.Formula = "" Then foo = foo + 1
If c.MergeCells Then Set skip = c.MergeArea

ElseIf Intersect(c, skip) Is Nothing Then

If c.Formula = "" Then foo = foo + 1
If c.MergeCells Then Set skip = Union(skip, c.MergeArea)

End If

Next c

End Function


In general, merged cells should be used as little as possible. Formulas based on
ranges are not the only bits of Excel functionality thoroughly screwed up by
merged cells. Without a doubt, one of the most problematic features in Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SUMIF with criteria "<>" & "=" 4
COUNTBLANK function 2
Counting Merged Cells 5
COUNTBLANK function 6
count nonblank cells 3
Count with merged cells 2
How to count merged cells 1
Isblank vs CountBlank 1

Top