Count merged cells as if unmerged
Hi Bernie,
The OP's question is highly ambiguous, but wouldn't adding
cell.MergeArea.Cells.Count result in an overly excessive count, where
multiple cells in a MergeArea are looped.
(My guess is the intention of the question is the opposite of what it says,
only count the first cell in the mergarea that matches the condition, but I
may well be wrong!)
Regards,
Peter T
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Count the number of merged cells:
If cell.Interior.color = 825735 Then intCount = intCount +
cell.MergeArea.Cells.Count
cell.MergeArea.Cells.Count will return 1 for cells that are not merged....
HTH,
Bernie
MS Excel MVP
"John" wrote in message
...
I had this neat macro that counts how many cells are a certain color:
Public Function CountColors(color As String) As Integer
Dim intCount As Integer
Dim cell As Range
For Each cell In Range("ThisRange").Cells
If cell.Interior.color = 825735 Then intCount = intCount + 1
Next cell
CountColors = intCount
End Function
The problem is, I have merged some cells. How can I get a macro to count
say, 3 cells merged into 1 as three cells, not 1, if they match a certain
color?.
|