Hi,
I have a series of buttons that when clicked, open the same user form. There is a link label on the user form that when clicked displays a particular tab in the spreadsheet depending on the button that was pressed. The code for the buttons is in Sheet1(Code), the Code for the user form is in UserForm1(Code). Basically I would like to know how I can set a variable when a button is clicked and then pass this to the UserForm1(Code) so that when the link is clicked the correct tab is opened on the spreadsheet dependent on the button that was pressed.
This is the Sub attached to the button
Then in a seperate location this is the Sub for the label.
What is the code for passing a variable between these two procedures?
Many thanks in advance for your help,
Chris
I have a series of buttons that when clicked, open the same user form. There is a link label on the user form that when clicked displays a particular tab in the spreadsheet depending on the button that was pressed. The code for the buttons is in Sheet1(Code), the Code for the user form is in UserForm1(Code). Basically I would like to know how I can set a variable when a button is clicked and then pass this to the UserForm1(Code) so that when the link is clicked the correct tab is opened on the spreadsheet dependent on the button that was pressed.
This is the Sub attached to the button
Code:
Private Sub CommandButton1_Click()
variable = 1
End Sub
Code:
Private Sub CommandButton2_Click()
variable = 2
End Sub
Then in a seperate location this is the Sub for the label.
Code:
Private Sub Label5_Click()
If variable = 1 Then ...
Else
If variable = 2 Then ...
End If
End Sub
What is the code for passing a variable between these two procedures?
Many thanks in advance for your help,
Chris