Count merged cells as if unmerged
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?.
|