The following code is okey. (The following code adds a rectangle.)
Sub Macro1()
ActiveSheet.Shapes.AddShape Type:=msoShapeRectangle, Left:=100, Top:=50, Width:=50, Height:=50
End Sub
The following code needs to be repaired.
Sub Macro2()
'Please enter msoShapeRectangle into A1 cell before running this macro.
'The following line throws Type mismatch error
ActiveSheet.Shapes.AddShape Type:=Range("A1").Value, Left:=100, Top:=150, Width:=50, Height:=50
End Sub
How to solve Type mismatch error?
I am asking this question because Shape Type is variable.
Thanks in advance.
New contributor
George Costanza is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.