Hi,
From my UserForm1 (Active Sheet is Project Definitions), when I make a selection, I would like to add a Form Control Button on my Sheet called "Start".
This part works when the selection is made in my UserForm1:
Sheets("Start").Buttons.Add(48, 196.5, 192, 19.5).Select
The Button is actually add to my Sheet called Start.
The problem I'm having is referencing the newly added Button (could be Button 1 thru Button x where x is some other number) so that I can assign a macro to the Button (Selection.OnAction = "ReturnToStart_Click"), and name the button i.e., Test.
When I ran the Record Macro this is the code produced:
Two issues in the above. 1) the code requires that the Sheet Start be active (I am on the Project Definitions sheet) and 2) how do I reference the newly added Button? Meaning How can I tell the Button added is Button 1, Button 2, etc.
In advance, thanks for the help.
From my UserForm1 (Active Sheet is Project Definitions), when I make a selection, I would like to add a Form Control Button on my Sheet called "Start".
This part works when the selection is made in my UserForm1:
Sheets("Start").Buttons.Add(48, 196.5, 192, 19.5).Select
The Button is actually add to my Sheet called Start.
The problem I'm having is referencing the newly added Button (could be Button 1 thru Button x where x is some other number) so that I can assign a macro to the Button (Selection.OnAction = "ReturnToStart_Click"), and name the button i.e., Test.
When I ran the Record Macro this is the code produced:
Code:
Sub Macro4()
'
' Macro4 Macro
'
'
ActiveSheet.Buttons.Add(48, 196.5, 192, 19.5).Select
Selection.OnAction = "ReturnToStart_Click"
ActiveSheet.Shapes("Button 7").Select
Selection.Characters.Text = "Test"
With Selection.Characters(Start:=1, Length:=4).Font
.Name = "Calibri"
.FontStyle = "Regular"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = 2
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("B14").Select
End Sub
Two issues in the above. 1) the code requires that the Sheet Start be active (I am on the Project Definitions sheet) and 2) how do I reference the newly added Button? Meaning How can I tell the Button added is Button 1, Button 2, etc.
In advance, thanks for the help.