Hi All.
I think it is easier to manually create shapes as a template then copy them where you want, multiple times instead of using VBA to create and place the shapes... maybe I am wrong.
I have Sheet1 with 3 option Buttons in a group box. I want to copy all 4 items to sheet2, 35 times and change the name and linked cell (output number) for each group of option buttons. It crashes at line commented below. Sometimes after the 1st time thru and sometimes after the 2nd time thru. I get an error of "There isn't enough memory to complete this action..."
Public Sub Paste_3_Button_Templet()
Dim my_cell As Range
Dim my_range As Range
Dim i As Integer
Dim left As Double
Dim number_of_copies As Integer
number_of_copies = 35
For i = 1 To number_of_copies
Sheet1.Activate
Sheet1.Shapes.Range(Array("Group Box Templet", "Option Button 1 Templet", "Option Button 2 Templet", "Option Button 3 Templet")).Select
Selection.Copy
Sheet2.Activate
Range("A2").Select
Sheet2.Paste
Sheet2.Shapes("Group Box Templet").Select
Sheet2.Shapes("Group Box Templet").Name = "Group Box " & i
Sheet2.Shapes("Option Button 1 Templet").Select
' Locks up after the previous line.
Sheet2.Shapes("Option Button 1 Templet").OLEFormat.Object.LinkedCell = Cells(1 + i, 6).Address
Selection.Name = "Option Button a " & i
Sheet2.Shapes("Option Button 2 Templet").Select
Selection.Name = "Option Button b " & i
Sheet2.Shapes("Option Button 3 Templet").Select
Selection.Name = "Option Button c " & i
Next i
End Sub
What is it? Thanks.
Bookmarks