passing data from userform to other userform

Bandito1

Board Regular
Joined
Oct 18, 2018
Messages
239
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

I use the follow code to open Userform 2 when "x" is put in column 5 or 6.
The labels on this form are filled with data from the same worksheet (Data Gel).

Code:
If Target.Column = 5 Or Target.Column = 6 Then  If Target.Value = "x" Then
    With UserForm2
     .lblGelCodeR.Caption = Cells(Target.Row, "A")
     .lblBatchNumberR.Caption = Cells(Target.Row, "B")
     .lblBoxR.Caption = Cells(Target.Row, "C")
     .lblProductNameR.Caption = Application.VLookup(Cells(Target.Row, "A"), Sheets("Products").Range("A:B"), 2, 0)
     .Show
   End With
  End If
End If


End Sub

Now i added a button on userform2 that opens the userform GelBMRproperties. I would like to pass the data that is in lblGelCodeR to the label lblGelCodeR that is also on the userformGelBMRproperties.

I tried something with commonvariable but it doesn't work.

Code:
Private Sub cmdInfo_Click()
Public commonVariable As String
commonVariable = lblGelCodeR.Caption
GelBMRProperties.Show
End Sub

Can someone help me?
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Use the name of the userform as well and see how you get on:

Code:
UserForm2.lblGelCodeR.Caption
 
Upvote 0

Forum statistics

Threads
1,223,713
Messages
6,174,043
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top