2 forms

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I have 2 forms. UserForm1 and UserForm2. Do I need to say
UserForm2.Label1.Caption
or just
Label1.Caption

I did "Label1.Caption" and everything work fine, it is not effecting the UserForm1

The code below is for UserForm2
Code:
Private Sub myadd_Click()
UserForm2.Label1.Caption = UserForm2.Label1.Caption + 1
End Sub


Private Sub mysub_Click()
Label1.Caption = Label1.Caption - 1
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
If you are in the form2 and you have open the form1 and you want to affect the form1 from the form2, then:

Code in form2
Code:
Private Sub myadd_Click()
UserForm[COLOR=#ff0000][B]1[/B][/COLOR].Label1.Caption = UserForm[B][COLOR=#ff0000]1[/COLOR][/B].Label1.Caption + 1
End Sub
 
Upvote 0
Ok I got it now why I need to mention that. Thank you all for the help. I appreciate it.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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