View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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