Hi SamT,
I had tried by removed those lines but it doesn't help.
I had modified the code to as below.
'Code to get the shape
Private Sub Green_Click()
Set myDocument = Worksheets(1)
myDocument.Shapes.AddShape(msoShapeRectangle, _
90, 90, 90, 50).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(0, 300, 0)
.BackColor.RGB = RGB(0, 300, 0)
.TwoColorGradient msoGradientHorizontal, 1
End With
With Selection.ShapeRange.Line
.ForeColor.RGB = RGB(0, 300, 0)
.BackColor.RGB = RGB(0, 300, 0)
End With
With SelectShapeColor
Unload Me
End With
End Sub
'Code for Calc Number of Shape
Sub CalcShape()
Dim sh As Sheet1
Dim shp As Shape
Dim a As Long
Dim b As Long
Dim CountShape As Long
For Each shp In Sheet1.Shapes
CountShape = 0
If shp.Fill.ForeColor.RGB = RGB(0, 300, 0) Then
Sheet1.Cells(2, 1) = CountShape + 1
End If
Next shp
End Sub
The result I got is "1" where actual I have 3 of similar color shapes.