Reeve
Reeve

Reputation: 17

Passing TextBox value between two UserForms

I have two user forms in Excel VBA. I enter a value in the TextBox at the first UserForm. How do I pass the value to the second UserForm to display same value in a TextBox too?

Upvotes: 0

Views: 8719

Answers (2)

Jake Duddy
Jake Duddy

Reputation: 36

You can declare a public variable:

i.e X. In user form 1 x=textbox1.value and in user form2 textbox2.value=X.

Upvotes: 0

Amen Jlili
Amen Jlili

Reputation: 1934

Assuming that your forms are named:

  • Userform1 for this first form
  • Userform2 for the second form

And assuming that you have two textboxes one in each form as follow:

  • TextBox1 for the first textbox located in your first form
  • TextBox2 for the second textbox located in the second form

You assign the value of the first TextBox1 to TextBox2 using Userform2.TextBox2.Text=Userform1.TextBox1.Text

Upvotes: 1

Related Questions