Hi All
I'm hoping this is simple. I have a userform that I want to copy data from to two worksheets.
The first worksheet if fixes, the second worksheet is chosen from a userform list box selection. The listbox is populated with the names of the worksheets automatically so I know the sheet names are correct.
Below is the code I'm trying to use. Any ideas on how i name the second worksheet would be greatly appreciated.
Cheers
Paul
I'm hoping this is simple. I have a userform that I want to copy data from to two worksheets.
The first worksheet if fixes, the second worksheet is chosen from a userform list box selection. The listbox is populated with the names of the worksheets automatically so I know the sheet names are correct.
Below is the code I'm trying to use. Any ideas on how i name the second worksheet would be greatly appreciated.
Cheers
Paul
Code:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("Register")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range("A" & LastRow).Value = TextBox1.Text
ws.Range("B" & LastRow).Value = TextBox2.Text
ws.Range("C" & LastRow).Value = TextBox3.Text
ws.Range("D" & LastRow).Value = TextBox4.Text
ws.Range("E" & LastRow).Value = TextBox5.Text
ws.Range("F" & LastRow).Value = TextBox6.Text
ws.Range("G" & LastRow).Value = TextBox7.Text
ws.Range("H" & LastRow).Value = TextBox8.Text
ws.Range("I" & LastRow).Value = TextBox9.Text
Dim LastRow1 As Long, ws1 As Worksheet
Set ws1 = Sheets(???ListBox1.Value???)
LastRow1 = ws1.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range("A" & LastRow1).Value = TextBox1.Text
ws.Range("B" & LastRow1).Value = TextBox2.Text
ws.Range("C" & LastRow1).Value = TextBox3.Text
ws.Range("D" & LastRow1).Value = TextBox4.Text
ws.Range("E" & LastRow1).Value = TextBox5.Text
ws.Range("F" & LastRow1).Value = TextBox6.Text
ws.Range("G" & LastRow1).Value = TextBox7.Text
ws.Range("H" & LastRow1).Value = TextBox8.Text
ws.Range("I" & LastRow1).Value = TextBox9.Text
Application.ScreenUpdating = True
End Sub