Help with userform

Shsolinzen

New Member
Joined
Jul 26, 2020
Messages
4
Office Version
  1. 2019
Platform
  1. 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
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi & welcome to MrExcel
It should be xlUp (lower case L, not numeral one)
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,871
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top