Run code from within a UserForm

P

Patrick C. Simonds

What I have is a DialogBox (called DataInput) with a large number of
TextBoxes and when I exit each one of the text boxes I wanted to run the
code below. So in an effort to reduce the number of lines of code, I had
hoped I could have just entered one line:

Module2.DisplayPay

But I get an object required error.


Sub DisplayPay()

Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox611.Value = rng(1, 99)
TextBox612.Value = rng(1, 104)
TextBox613.Value = rng(1, 109)
TextBox614.Value = rng(1, 114)
TextBox615.Value = rng(1, 119)

End Sub
 
C

Chip Pearson

You need to prefix the TextBox controls with the name of the userform.
E.g.,

UserForm1.TextBox611.Text = rng(1,99)

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
P

Patrick C. Simonds

Thank you

Chip Pearson said:
You need to prefix the TextBox controls with the name of the userform.
E.g.,

UserForm1.TextBox611.Text = rng(1,99)

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Have TextBox display a dollar value 6
Dim statement 8
UserForm past data 7
Date value 7
Create a public variable 4
Referencing a UserForm 2
Stumped 1
Return to UserForm 2

Top