Update multiple textboxes on userform

P

pswanie

Would there be a loop code i can use to do the following?

Pritate Sub textbox1_change()
sheet2.select
sheet2.range("c1").select
selection.value=userform2.textbox1.value
label101.caption=sheet2.range("e1").value
end sub

Pritate Sub textbox2_change()
sheet2.select
sheet2.range("c2").select
selection.value=userform2.textbox2.value
label102.caption=sheet2.range("e2").value
end sub


Pritate Sub textbox3_change()
sheet2.select
sheet2.range("c3").select
selection.value=userform2.textbox3.value
label103.caption=sheet2.range("e3").value
end sub
 
D

Dave Peterson

First, it's better to copy your actual code into your message than to type it in
manually. It can be difficult to debug things if the error isn't in the real
code--just in the typed in code.

But you could add a button onto your userform that does all the processing (and
remove all the textbox#_change events.

Option Explicit
Private Sub CommandButton1_Click()

Dim iCtr As Long
For iCtr = 1 To 3
Sheet2.Cells(iCtr, "C").Value = Me.Controls("textbox" & iCtr).Value
Me.Controls("Label10" & iCtr).Caption = Sheet2.Cells(iCtr, "E").Value
Next iCtr

End Sub

I assumed that all these procedures were in the UserForm2 module.
 

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

Top