View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
[email protected] bart.smissaert@gmail.com is offline
external usenet poster
 
Posts: 18
Default countbycolor counts all cells in a merged cell

but I need it count a merged cell as a single cell

Yes, and that is what my posted sub does.

RBS


dsamson wrote:
The code I was working with is:

Function CountByColor(InputRange As Range, ColorRange As Range) As
Long
Dim cl As Range, TempCount As Long, ColorIndex As Integer
ColorIndex = ColorRange.Cells(1, 1).Interior.ColorIndex
TempCount = 0

For Each cl In InputRange.Cells

If cl.Interior.ColorIndex = ColorIndex Then
TempCount = TempCount + 1
End If
If cl.MergeCells = True Then
Next cl
End If

Next cl
Set cl = Nothing
CountByColor = TempCount
End Sub

This works well, but I need it count a merged cell as a single cell,
vice the number of cells merged.

Thanks.


--
dsamson
------------------------------------------------------------------------
dsamson's Profile: http://www.excelforum.com/member.php...o&userid=35528
View this thread: http://www.excelforum.com/showthread...hreadid=552955