Hello,
I have built a userform and I want the data from the userform to be entered into a specific range of cells. Right now the code finds the last available row but I want the userform to enter data into specific cells. Paritularly, I want the first data from my textboxes to be entered into cells B7:E7 of a particular active sheet (chosen from a combobox), and then the next userform will enter data in cells B:8:E7, all the way down to B12:E12. Below is the code I am currently using:
Private Sub CommandButton1_Click()
TargetSheet = ComboBox1.Value
If TargetSheet = "" Then
Exit Sub
End If
Worksheets(TargetSheet).Activate
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
ActiveSheet.Cells(lastrow + 1, 2).Value = TextBox1.Value
ActiveSheet.Cells(lastrow + 1, 3).Value = TextBox2.Value
ActiveSheet.Cells(lastrow + 1, 4).Value = TextBox3.Value
ActiveSheet.Cells(lastrow + 1, 5).Value = TextBox4.Value
MsgBox ("Data upload to Summary Tab Complete")
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
Thank you for the help!
I have built a userform and I want the data from the userform to be entered into a specific range of cells. Right now the code finds the last available row but I want the userform to enter data into specific cells. Paritularly, I want the first data from my textboxes to be entered into cells B7:E7 of a particular active sheet (chosen from a combobox), and then the next userform will enter data in cells B:8:E7, all the way down to B12:E12. Below is the code I am currently using:
Private Sub CommandButton1_Click()
TargetSheet = ComboBox1.Value
If TargetSheet = "" Then
Exit Sub
End If
Worksheets(TargetSheet).Activate
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
ActiveSheet.Cells(lastrow + 1, 2).Value = TextBox1.Value
ActiveSheet.Cells(lastrow + 1, 3).Value = TextBox2.Value
ActiveSheet.Cells(lastrow + 1, 4).Value = TextBox3.Value
ActiveSheet.Cells(lastrow + 1, 5).Value = TextBox4.Value
MsgBox ("Data upload to Summary Tab Complete")
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
Thank you for the help!