One Userform, Multiple Fields

begoldar

Board Regular
Joined
Dec 20, 2005
Messages
98
Hi Everyone,

I have created a userform that has several text boxes that when you double-click will open a new (second) userform - has a calander function. I would like to use this SAME new userform (#2) for more than one text box. Is there a way to set it up so that only the activated textbox (on form #1), the one I double-clicked, gets the data input into it?

Right now I made 4 copies of the form #2 and had each text box on form #1 call a different copy. I want to get rid of 3 of those copies and just use one single version of #2 for all 4 text boxes. Thanks for the help!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
This worked for me:

Code:
'General module
Public TB As Object

'UserForm1 module
Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Set TB = TextBox1
    UserForm2.Show
End Sub

Private Sub TextBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Set TB = TextBox2
    UserForm2.Show
End Sub

Private Sub TextBox3_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Set TB = TextBox3
    UserForm2.Show
End Sub

'UserForm2 module
Private Sub CommandButton1_Click()
    TB.Text = Calendar1.Value
    Unload UserForm2
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

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