Run code from within a UserForm
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 |
Run code from within a UserForm
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) On Wed, 18 Mar 2009 11:27:56 -0700, "Patrick C. Simonds" wrote: 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 |
Run code from within a UserForm
Thank you
"Chip Pearson" wrote in message ... 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) On Wed, 18 Mar 2009 11:27:56 -0700, "Patrick C. Simonds" wrote: 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 |
All times are GMT +1. The time now is 04:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com