Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default UserForm Question

Hello
I have a created a userform and would like the values in txtBox3-txtBox10 to
default to the value in txtBox1 once it is entered. So if I enter 100 in
txtBox1 and then go to txtBox2 the values in 3-7 will be 100 also. I am new
to user forms and I dont know how to do this. All help would be greatly
appreciated!
Thanks in advance
Sharon
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default UserForm Question

TextBoxes have a Change event. You might be able to use this to set
txtBox2.Text = txtBox1.Text, etc.

HTH
Ed

"Sharon" wrote in message
...
Hello
I have a created a userform and would like the values in txtBox3-txtBox10

to
default to the value in txtBox1 once it is entered. So if I enter 100 in
txtBox1 and then go to txtBox2 the values in 3-7 will be 100 also. I am

new
to user forms and I dont know how to do this. All help would be greatly
appreciated!
Thanks in advance
Sharon



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default UserForm Question



Private Sub TextBox1_Change()
With Me.TextBox1
TextBox2.Text = .Text
TextBox3.Text = .Text
TextBox4.Text = .Text
TextBox5.Text = .Text
TextBox6.Text = .Text
TextBox7.Text = .Text
End With
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sharon" wrote in message
...
Hello
I have a created a userform and would like the values in txtBox3-txtBox10

to
default to the value in txtBox1 once it is entered. So if I enter 100 in
txtBox1 and then go to txtBox2 the values in 3-7 will be 100 also. I am

new
to user forms and I dont know how to do this. All help would be greatly
appreciated!
Thanks in advance
Sharon



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default UserForm Question

Use the exit event of the Textbox1

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If trim(Textbox1.Text) < "" then
for i = 3 to 10
me.controls("TextBox" & i).Text = Textbox1.Text
Next
End if
End Sub

If you only want this behavior if the textboxes 3 to 10 are empty

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If trim(Textbox1.Text) < "" then
for i = 3 to 10
if trim(me.controls("Textbox" & i).Text) = "" then
me.controls("TextBox" & i).Text = Textbox1.Text
End if
Next
End if
End Sub


--
Regards,
Tom Ogilvy

"Sharon" wrote in message
...
Hello
I have a created a userform and would like the values in txtBox3-txtBox10

to
default to the value in txtBox1 once it is entered. So if I enter 100 in
txtBox1 and then go to txtBox2 the values in 3-7 will be 100 also. I am

new
to user forms and I dont know how to do this. All help would be greatly
appreciated!
Thanks in advance
Sharon



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default UserForm Question

Thanks Bob
A followup question:
How would I modify if in textBox8 and TextBox9 the values 2 and 5
respectively for it to change textBox2 through textBox5, and not 6 and 7?
Thanks!


"Bob Phillips" wrote:



Private Sub TextBox1_Change()
With Me.TextBox1
TextBox2.Text = .Text
TextBox3.Text = .Text
TextBox4.Text = .Text
TextBox5.Text = .Text
TextBox6.Text = .Text
TextBox7.Text = .Text
End With
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sharon" wrote in message
...
Hello
I have a created a userform and would like the values in txtBox3-txtBox10

to
default to the value in txtBox1 once it is entered. So if I enter 100 in
txtBox1 and then go to txtBox2 the values in 3-7 will be 100 also. I am

new
to user forms and I dont know how to do this. All help would be greatly
appreciated!
Thanks in advance
Sharon






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default UserForm Question

Enamored with repetitiveness you asked:
How would I modify if in textBox8 and TextBox9 the values 2 and 5
respectively for it to change textBox2 through textBox5, and not 6 and 7?


Private Sub TextBox1_Change()
With Me.TextBox1
TextBox2.Text = .Text
TextBox3.Text = .Text
TextBox4.Text = .Text
TextBox5.Text = .Text
' TextBox6.Text = .Text
' TextBox7.Text = .Text
TextBox8.Text = 2
TextBox9.Text = 5
End With
End Sub

However, using the exit event would be a better choice.

--
Regards,
Tom Ogilvy


"Sharon" wrote in message
...
Thanks Bob
A followup question:
How would I modify if in textBox8 and TextBox9 the values 2 and 5
respectively for it to change textBox2 through textBox5, and not 6 and 7?
Thanks!


"Bob Phillips" wrote:



Private Sub TextBox1_Change()
With Me.TextBox1
TextBox2.Text = .Text
TextBox3.Text = .Text
TextBox4.Text = .Text
TextBox5.Text = .Text
TextBox6.Text = .Text
TextBox7.Text = .Text
End With
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sharon" wrote in message
...
Hello
I have a created a userform and would like the values in

txtBox3-txtBox10
to
default to the value in txtBox1 once it is entered. So if I enter 100

in
txtBox1 and then go to txtBox2 the values in 3-7 will be 100 also. I

am
new
to user forms and I dont know how to do this. All help would be

greatly
appreciated!
Thanks in advance
Sharon






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default UserForm Question

Im sorry thats not quite what I meant.....
TextBox1 user enters 100
Textbox8 user enters 2
TextBox9 user enters 5
and then form is updated TextBox2 through TextBox5 =100 TextBox6 and
TextBox7 are blank.
So the code reads TextBox8 and TextBox9 and then fills in 2-7 based on whats
entered in 8 and 9.

Sorry for the lack of clarity---it made perfect sense to me LOL
I hoep this clarifies a bit

"Tom Ogilvy" wrote:

Enamored with repetitiveness you asked:
How would I modify if in textBox8 and TextBox9 the values 2 and 5
respectively for it to change textBox2 through textBox5, and not 6 and 7?


Private Sub TextBox1_Change()
With Me.TextBox1
TextBox2.Text = .Text
TextBox3.Text = .Text
TextBox4.Text = .Text
TextBox5.Text = .Text
' TextBox6.Text = .Text
' TextBox7.Text = .Text
TextBox8.Text = 2
TextBox9.Text = 5
End With
End Sub

However, using the exit event would be a better choice.

--
Regards,
Tom Ogilvy


"Sharon" wrote in message
...
Thanks Bob
A followup question:
How would I modify if in textBox8 and TextBox9 the values 2 and 5
respectively for it to change textBox2 through textBox5, and not 6 and 7?
Thanks!


"Bob Phillips" wrote:



Private Sub TextBox1_Change()
With Me.TextBox1
TextBox2.Text = .Text
TextBox3.Text = .Text
TextBox4.Text = .Text
TextBox5.Text = .Text
TextBox6.Text = .Text
TextBox7.Text = .Text
End With
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sharon" wrote in message
...
Hello
I have a created a userform and would like the values in

txtBox3-txtBox10
to
default to the value in txtBox1 once it is entered. So if I enter 100

in
txtBox1 and then go to txtBox2 the values in 3-7 will be 100 also. I

am
new
to user forms and I dont know how to do this. All help would be

greatly
appreciated!
Thanks in advance
Sharon






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default UserForm Question

All placed in the userform code module

Sub UpdateBoxes()
Dim j as Long, k as Long, i as Long
if isnumeric(me.Textbox8.Text) then _
j = clng(me.Textbox8.Text)
if isnumeric(me.Textbox9.Text) then _
k = clng(me.Textbox9.Text)
if j < 2 or j 7 or k < 2 or k 7 then exit sub
for i = j to k
me.Controls("TextBox" & i).Text = Textbox1.Text
Next
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
UpdateBoxes
End Sub


Private Sub TextBox8_Exit(ByVal Cancel As MSForms.ReturnBoolean)
UpdateBoxes
End Sub


Private Sub TextBox9_Exit(ByVal Cancel As MSForms.ReturnBoolean)
UpdateBoxes
End Sub


--
Regards,
Tom Ogilvy



"Sharon" wrote in message
...
Im sorry thats not quite what I meant.....
TextBox1 user enters 100
Textbox8 user enters 2
TextBox9 user enters 5
and then form is updated TextBox2 through TextBox5 =100 TextBox6 and
TextBox7 are blank.
So the code reads TextBox8 and TextBox9 and then fills in 2-7 based on

whats
entered in 8 and 9.

Sorry for the lack of clarity---it made perfect sense to me LOL
I hoep this clarifies a bit

"Tom Ogilvy" wrote:

Enamored with repetitiveness you asked:
How would I modify if in textBox8 and TextBox9 the values 2 and 5
respectively for it to change textBox2 through textBox5, and not 6 and

7?

Private Sub TextBox1_Change()
With Me.TextBox1
TextBox2.Text = .Text
TextBox3.Text = .Text
TextBox4.Text = .Text
TextBox5.Text = .Text
' TextBox6.Text = .Text
' TextBox7.Text = .Text
TextBox8.Text = 2
TextBox9.Text = 5
End With
End Sub

However, using the exit event would be a better choice.

--
Regards,
Tom Ogilvy


"Sharon" wrote in message
...
Thanks Bob
A followup question:
How would I modify if in textBox8 and TextBox9 the values 2 and 5
respectively for it to change textBox2 through textBox5, and not 6 and

7?
Thanks!


"Bob Phillips" wrote:



Private Sub TextBox1_Change()
With Me.TextBox1
TextBox2.Text = .Text
TextBox3.Text = .Text
TextBox4.Text = .Text
TextBox5.Text = .Text
TextBox6.Text = .Text
TextBox7.Text = .Text
End With
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sharon" wrote in message
...
Hello
I have a created a userform and would like the values in

txtBox3-txtBox10
to
default to the value in txtBox1 once it is entered. So if I enter

100
in
txtBox1 and then go to txtBox2 the values in 3-7 will be 100 also.

I
am
new
to user forms and I dont know how to do this. All help would be

greatly
appreciated!
Thanks in advance
Sharon








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
userform question [email protected] Excel Discussion (Misc queries) 0 May 29th 09 12:01 AM
UserForm Question Mr BT[_3_] Excel Worksheet Functions 0 August 20th 07 04:56 AM
VBA UserForm Question.......Help! Sam Torasco Excel Programming 6 July 19th 04 01:23 PM
UserForm question Doug[_9_] Excel Programming 1 January 1st 04 10:05 PM
userform question David Goodall Excel Programming 0 August 25th 03 07:10 PM


All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"