Updating Worksheet from Userform TextBoxes

  • Thread starter Thread starter Alan T
  • Start date Start date
A

Alan T

I have a userform with 15 textboxes on it. I'm looking for help t
update a cell on the worksheet using the data from the first populate
textbox (in some cases only 1 textbox will be populated, in others i
could be 10 or more boxes which are populated
 
If you name your textboxes consecutively (textbox1, ..., textbox15), it makes
life a little easier:

Option Explicit
Private Sub CommandButton1_Click()

Dim iCtr As Long

For iCtr = 1 To 15
If Trim(Me.Controls("textbox" & iCtr).Text) = "" Then
'do nothing
Else
Worksheets("sheet1").Range("a1").Value _
= Me.Controls("textbox" & iCtr).Text
Exit For
End If
Next iCtr

End Sub
 
Not a problem if I read it correctly. Excel will obligingly put an empt
string when required.

Private Sub CommandButton1_Click()
Dim Mystring As String
Mystring = UserForm1.TextBox1.Value _
& UserForm1.TextBox2.Value _
& UserForm1.TextBox3.Value
ActiveSheet.Range("A1").Value = Mystring
End Su
 
Back
Top