I was asked to continu a code on VBA Excel on the following code :
Sub Ajout_45()
Ajout (45)
End Sub
Sub Ajout_60()
Ajout (60)
End Sub
Sub Ajout(diametre)
Dim nomforme As String
Dim basenom As String
basenom = "Forme_"
If (diametre = 45) Then
nomforme = basenom + "45"
ElseIf (diametre = 60) Then
nomforme = basenom + "60"
End If
ActiveSheet.Shapes(nomforme).Copy
Application.Wait (Now + TimeValue("0:00:01"))
ActiveSheet.Paste
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 204, 153)
Selection.ShapeRange.Name = compt
compt = compt + 1
Selection.OnAction = "Etat"
End Sub
This is my first time using VBA so I'm trying to understand the code. What I understand basically is it creates a shape based on a shape already existing. It copy and paste it. Then fill the new shape color with RGB given. Then give a name to the new shape. Then call on click the macro Etat. If I miss something or I am wrong somewhere please let me know.
My second question is why if comment the line Selection.OnAction = "Etat"
every new shape created keep as macro creating new shape.
Many thanks in advance for any helpers!