Shsolinzen
New Member
- Joined
- Jul 26, 2020
- Messages
- 4
- Office Version
- 2019
- Platform
- Windows
I am using this code for a command button to submit values into a worksheet through the userform. I am getting runtime error 1004 after clicking the button, application defined or object defined error. I have 9 columns. I want the 5th column to be left alone(nothing goes in it). How can I fix this so that the values input beginning on a specific cell. In this case it would be A13. I enter a value into txtDate, then the next cell would be active and the value for txtFrom would be entered and so on. Except that the 5th cell(E) would be skipped over. Also, I am trying to get this userform to be compatible with 12 sheets in a workbook. All the sheets in the workbook are exactly alike.
Private Sub cmdSubmit_Click()
Dim erow As Long
erow = ActiveSheet.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row
Cells(erow, 1) = txtDate
Cells(erow, 2) = txtFrom
Cells(erow, 3) = txtTo
Cells(erow, 4) = txtEndOdomReading
Cells(erow, 6) = txtFuelCost
Cells(erow, 7) = txtGallons
Cells(erow, 8) = txtProgramCode
Cells(erow, 9) = txtOperator
End Sub
Private Sub cmdSubmit_Click()
Dim erow As Long
erow = ActiveSheet.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row
Cells(erow, 1) = txtDate
Cells(erow, 2) = txtFrom
Cells(erow, 3) = txtTo
Cells(erow, 4) = txtEndOdomReading
Cells(erow, 6) = txtFuelCost
Cells(erow, 7) = txtGallons
Cells(erow, 8) = txtProgramCode
Cells(erow, 9) = txtOperator
End Sub