User form issues

E

Ewing25

I want to take data that users input into a User form into the spread sheet.

I currently have 4 text boxes that are called:

TextBox1
TextBox2
TextBox3
TextBox4

I would like TB1 to input into Column A,
TB2 into Column C,
TB3 into Column D,
TB4 into Column E.


The worksheet is named "Expense Non Amex"

If its possible id like the form to repeat if the New Reciept Button is
pushed and again until the button called Done is selected.

Thank you very much!!
 
J

JLGWhiz

I could have made this a few lines shorter, but this way you can see what is
happening for each text box by reading the code. Put this code in the code
window behind your UserForm. Right click the UserForm, then click view code
in the drop down menu to open the code window.

Private Sub CommandButton1_Click() 'Change button, if required
Set wks = Worksheets("Expense Non Amex")
lrA = wks.Cells(Rows.Count, 1).End(xlUp).Row
lrB = wks.Cells(Rows.Count, 2).End(xlUp).Row
lrC = wks.Cells(Rows.Count, 3).End(xlUp).Row
lrD = wks.Cells(Rows.Count, 4).End(xlUp).Row
wks.Range("A" & lrA + 1) = TextBox1.Text
wks.Range("B" & lrA + 1) = TextBox2.Text
wks.Range("C" & lrA + 1) = TextBox3.Text
wks.Range("D" & lrA + 1) = TextBox4.Text
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub


Private Sub CommandButton2_Click() 'Change button, if required
Unload UserForm1 'Change form name, if required
End Sub

You can put a call-up macro in the standard code module to activate your
form with the following code.

Sub callMyForm()
UserForm1.Show 'Change form name, if required
End Sub

Just make sure that all of the control names, sheetnames and form names are
changed to match what you are using.
 
E

Ewing25

Amazing thank you very much!

JLGWhiz said:
I could have made this a few lines shorter, but this way you can see what is
happening for each text box by reading the code. Put this code in the code
window behind your UserForm. Right click the UserForm, then click view code
in the drop down menu to open the code window.

Private Sub CommandButton1_Click() 'Change button, if required
Set wks = Worksheets("Expense Non Amex")
lrA = wks.Cells(Rows.Count, 1).End(xlUp).Row
lrB = wks.Cells(Rows.Count, 2).End(xlUp).Row
lrC = wks.Cells(Rows.Count, 3).End(xlUp).Row
lrD = wks.Cells(Rows.Count, 4).End(xlUp).Row
wks.Range("A" & lrA + 1) = TextBox1.Text
wks.Range("B" & lrA + 1) = TextBox2.Text
wks.Range("C" & lrA + 1) = TextBox3.Text
wks.Range("D" & lrA + 1) = TextBox4.Text
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub


Private Sub CommandButton2_Click() 'Change button, if required
Unload UserForm1 'Change form name, if required
End Sub

You can put a call-up macro in the standard code module to activate your
form with the following code.

Sub callMyForm()
UserForm1.Show 'Change form name, if required
End Sub

Just make sure that all of the control names, sheetnames and form names are
changed to match what you are using.
 

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