Hi John,
This is probably overkill, but look at the part of the code after it counts
colorindexes and then offers a Message Box...
Sub ColorCount()
'Counts the number of colored
'cells in a range named Data.
Dim Blue5 As Integer
Dim Red3 As Integer
Dim Green4 As Integer
Dim Yellow6 As Integer
Dim Cell As Range
For Each Cell In Range("Data") '("B1:F11")
If Cell.Interior.ColorIndex = 5 Then
Blue5 = Blue5 + 1
ElseIf Cell.Interior.ColorIndex = 3 Then
Red3 = Red3 + 1
ElseIf Cell.Interior.ColorIndex = 4 Then
Green4 = Green4 + 1
ElseIf Cell.Interior.ColorIndex = 6 Then
Yellow6 = Yellow6 + 1
End If
Next
Range("A1").Value = Blue5 & " Blue"
Range("A2").Value = Red3 & " Red"
Range("A3").Value = Green4 & " Green"
Range("A4").Value = Yellow6 & " Yellow"
'Here is the Msgbox code...
MsgBox " You have: " & vbCr _
& vbCr & " Blue " & Blue5 _
& vbCr & " Red " & Red3 _
& vbCr & " Green " & Green4 _
& vbCr & " Yellow " & Yellow6, _
vbOKOnly, "CountColor"
End Sub
Where Blue will be text, "Blue 5" will be the number of Blue text cells and
so on with other colors and "vbCr" will produce a carriage return.
Code in "..." will appear as text, others will appear as values and note the
spaces here and other lines that will center up the message text in the
message box.
"& vbCr & " Blue "
"Blue5 _", with the underscore after Blue5 lets you consolidate your code in
the VB Editor (kinda like a carriage return, but only in the VB Editor), for
clarity and editing the message box in code but not on the worksheet.
Somehow I have misplaced D_McRitchies professional advice on this solution,
but it is out there. This may get you going.
Glad to help with any questions, post back.
HTH,
Regards,
Howard