As you can see, each color constant has a specific value (no gray constant) Depending on how each shape's color was assigned, the color constant may not have the exact same value that the shape has.
Bottom line, you need to refine your stated requirement.
Skip,
[sub]
Just traded in my OLD subtlety...
for a NUance![/sub]
Hi SkipVought, Mintjulep
I had assigned another macro to insert the shapes with fixed color (vbRed, vbGreen, etc)
Then I'm stuck to get the number of shapes count.
What I need is, lets say I have 3 green shapes, 2 red shapes, 2 yellow shapes, I want the result to be show as
Cell (1,1): 3 (for green)
Cell (1,2): 2 (for red)
Cell (1,3): 2 (for yellow)
and so on
You need a loop [tt]For Each xShape in ActiveSheet.Shapes[/tt], do three colour tests for xShape ForeColor, increase proper temporary variables or target cells if any test passed, and finally fill target cells with results (if working immediately with target cells, clear theif contents before initialising the loop).
Hi,
Below is the code for color selection.
[highlight #204A87]Private Sub Green_Click()
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 70, 206, _
172, 91).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = vbGreen
.BackColor.RGB = vbGreen
.ForeColor.Brightness = 0.8
.Solid
End With
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = vbGreen
.ForeColor.Brightness = 0.8
.Transparency = 0
End With
With SelectShapeColor
Unload Me
End With
End Sub
The number of shapes of each colors may up to 100+ in the end, I cant really remember how much of each color I had added.
Thus, I need a summary of the total number of shapes of each color added in the excel sheet.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.