I'm doing my first UserForm and I have a Submit button on the form for users to click which should then write the data from the various list boxes to the worksheet. I've adapted the code from a textbook example so I thought I'd be ok, but where I want it to start writing the data from the first empty cell in column H and go across, it's dropping the data into cell A2, B2 etc. - overwriting existing data in the worksheet.
Can anyone tell me where I'm going wrong please?
Code
Private Sub CommandButton1_Click()
Dim lngEntryRow As Long
Worksheets("Sheet1").Activate
lngEntryRow = Worksheets("Sheet1").Range("H1048576").End(xlUp).Row + 1
Cells(lngEntryRow, 1) = ListBox1.Value
Cells(lngEntryRow, 2) = ListBox2.Value
Cells(lngEntryRow, 3) = ListBox3.Value
Cells(lngEntryRow, 4) = ListBox4.Value
Cells(lngEntryRow, 5) = ListBox5.Value
Cells(lngEntryRow, 6) = ListBox6.Value
Cells(lngEntryRow, 7) = ListBox7.Value
Cells(lngEntryRow, 8) = ListBox8.Value
Cells(lngEntryRow, 8).Activate
End Sub
Display More
Thanks