PDA

View Full Version : Active X Textbox Content to Userform Textbox



swaggerbox
12-14-2019, 10:41 PM
I have a workbook with multiple active x textboxes. I want to have expanded view for each textbox and would prefer a userform textbox. Each time the user double clicks on the active x textbox, the userform is displayed filled with the contents of the active x textbox. In the userform, the user can edit the content and save the content back to the active textbox as well. I don't want to create multiple userforms for each active textbox and would prefer only one. My problem is how to code macro telling which active textbox to import. I have attached a sample workbook to illustrate this problem.

snb
12-15-2019, 04:29 AM
Although I don't see any benefit in this approach:


Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
UserForm1.Tag = 1
UserForm1.Show
End Sub

Private Sub TextBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
UserForm1.Tag = 2
UserForm1.Show
End Sub

Private Sub UserForm_Activate()
TextBox1 = Sheet1.OLEObjects("TextBox" & Tag).Object.Text
End Sub

Private Sub CommandButton2_Click()
Sheet1.OLEObjects("TextBox" & Tag).Object.Text = TextBox1
Hide
End Sub

Private Sub CommandButton1_Click()
Hide
End Sub

swaggerbox
12-15-2019, 03:07 PM
you again saved the day snb. thank you!