Within Excel VBA I have a User Form similar to the following where the user enters an ID number and then the details are displayed on the user form:
Private
There are many many ways... Here are some...
Way 1
Public Variable in a ModuleIn Userform1
Private Sub CommandButton1_Click()
MyVal = "Sid"
UserForm2.Show
End Sub
In Userform2
Private Sub CommandButton1_Click()
MsgBox MyVal
End Sub
In Module
Public MyVal
Way 2
Use the .Tag property of the userform
In Userform1
Private Sub CommandButton1_Click()
UserForm2.Tag = "Sid"
UserForm2.Show
End Sub
In Userform2
Private Sub CommandButton1_Click()
MsgBox Me.Tag
End Sub
Way 3
Add a Label in Userform2 and set it's visible property to False
In Userform1
Private Sub CommandButton1_Click()
UserForm2.Label1.Caption = "Sid"
UserForm2.Show
End Sub
In Userform2
Private Sub CommandButton1_Click()
MsgBox Label1.Caption
End Sub