I have a spreadsheet that contains pasted data from an online database. The
imported cells are color coded with RED, YELLOW, and GREEN fill. I would
like an automated way to calculate the number of RED, YELLOW, and GREEN cells
in the data. Any thoughts?
Hi
Have a look he
www.cpearson.com/excel/colors.htm
Andy.
quot;Robquot; gt; wrote in message
news
gt;I have a spreadsheet that contains pasted data from an online database.
gt;The
gt; imported cells are color coded with RED, YELLOW, and GREEN fill. I would
gt; like an automated way to calculate the number of RED, YELLOW, and GREEN
gt; cells
gt; in the data. Any thoughts?
Chip's site will give you everything to do that. For grins, here's my shot
at it. Adjust to suit your range.
Will not work if color is from conditional formatting.
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(quot;Dataquot;) '(quot;B1:F11quot;)
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(quot;A1quot;).Value = Blue5 amp; quot; Bluequot;
Range(quot;A2quot;).Value = Red3 amp; quot; Redquot;
Range(quot;A3quot;).Value = Green4 amp; quot; Greenquot;
Range(quot;A4quot;).Value = Yellow6 amp; quot; Yellowquot;
MsgBox quot; You have: quot; amp; vbCr _
amp; vbCr amp; quot; Blue quot; amp; Blue5 _
amp; vbCr amp; quot; Red quot; amp; Red3 _
amp; vbCr amp; quot; Green quot; amp; Green4 _
amp; vbCr amp; quot; Yellow quot; amp; Yellow6, _
vbOKOnly, quot;CountColorquot;
End Sub
HTH
regards,
Howard
quot;Robquot; gt; wrote in message
news
gt;I have a spreadsheet that contains pasted data from an online database.
gt;The
gt; imported cells are color coded with RED, YELLOW, and GREEN fill. I would
gt; like an automated way to calculate the number of RED, YELLOW, and GREEN
gt; cells
gt; in the data. Any thoughts?
- Jul 16 Mon 2007 20:38
How do I sort or count cells by fill color?
close
全站熱搜
留言列表
發表留言