sharky12345
08-23-2010, 02:30 AM
I know someone is going to come up trumps with the answer!
I have a userform where people enter data, then that data is entered into the next empty row on the worksheet.
I've worked out the code as below;
Private Sub CommandButton12_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ws.Cells(iRow, 3).Value = Me.txtrms1.Value
ws.Cells(iRow, 4).Value = Me.txttimeon1.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff1.Value
ws.Cells(iRow, 6).Value = Me.txtcomments1.Value
ws.Cells(iRow, 3).Value = Me.txtrms2.Value
ws.Cells(iRow, 4).Value = Me.txttimeon2.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff2.Value
ws.Cells(iRow, 6).Value = Me.txtcomments2.Value
ws.Cells(iRow, 3).Value = Me.txtrms3.Value
ws.Cells(iRow, 4).Value = Me.txttimeon3.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff3.Value
ws.Cells(iRow, 6).Value = Me.txtcomments3.Value
Here's the problem - what I want the form to do is to enter the data from the 'txt1' boxes into the first empty row and then the data from the 'txt2' boxes into the next row, after the '1' data, and so on.
I can't work out how to do this - can anyone help?
I have a userform where people enter data, then that data is entered into the next empty row on the worksheet.
I've worked out the code as below;
Private Sub CommandButton12_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ws.Cells(iRow, 3).Value = Me.txtrms1.Value
ws.Cells(iRow, 4).Value = Me.txttimeon1.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff1.Value
ws.Cells(iRow, 6).Value = Me.txtcomments1.Value
ws.Cells(iRow, 3).Value = Me.txtrms2.Value
ws.Cells(iRow, 4).Value = Me.txttimeon2.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff2.Value
ws.Cells(iRow, 6).Value = Me.txtcomments2.Value
ws.Cells(iRow, 3).Value = Me.txtrms3.Value
ws.Cells(iRow, 4).Value = Me.txttimeon3.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff3.Value
ws.Cells(iRow, 6).Value = Me.txtcomments3.Value
Here's the problem - what I want the form to do is to enter the data from the 'txt1' boxes into the first empty row and then the data from the 'txt2' boxes into the next row, after the '1' data, and so on.
I can't work out how to do this - can anyone help?