VBA code to count colors/shapes?
Sub test()
Dim shp As Shape
Dim nRed As Long
Dim nBlue As Long
For Each shp In ActiveSheet.Shapes
Select Case shp.Fill.ForeColor.SchemeColor
Case 10: nRed = nRed + 1
Case 12: nBlue = nBlue + 1
End Select
Next shp
End Sub
You will have to experiment to see what the schemecolor values are, they are
not the sam e as colorindex (!)
--
HTH
Bob Phillips
"Nimrod" wrote in message
...
I've gotten great help from this group recently and am thankful. I'm
hopeful someone has an answer (or web link) for the following need. I
have
a worksheet that has about 100 rectangles that have been renamed to
various
names. Some of these rectangles are red, others blue, and so forth.
Is there any VBA code that will allow me to total how many of these
rectangles are red, how many are blue, then plant those figures into a
cell
so I can total them up and create a graph?
|