Runtime error '424' issue

mmaeng13

New Member
Joined
Aug 29, 2017
Messages
25
I am running into the runtime error '424' Object required issue. I am using the variable eRow in order to enter data from a userform into the next available row in a excel sheet. I can't find any issues with the code, it was working a couple weeks ago.

Here is a shortened version of what I am using.

Code:
Private Sub Enter_Click()


eRow = Database.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row


Cells(eRow, 1).Value = Day.Text
Cells(eRow, 2).Value = PMEHours.Text
Cells(eRow, 3).Value = PMEGallons.Text
Cells(eRow, 4).Value = SMEHours.Text


End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I am running into the runtime error '424' Object required issue. I am using the variable eRow in order to enter data from a userform into the next available row in a excel sheet. I can't find any issues with the code, it was working a couple weeks ago.

Here is a shortened version of what I am using.

Code:
Private Sub Enter_Click()


eRow = Database.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row


Cells(eRow, 1).Value = Day.Text
Cells(eRow, 2).Value = PMEHours.Text
Cells(eRow, 3).Value = PMEGallons.Text
Cells(eRow, 4).Value = SMEHours.Text


End Sub
Usually "shortened versions" of code tend to omit what we need to see. Based on what you posted, I would say all four of your assignment lines would cause that error as you using Day (a terrible name as it is also a built-in VB function name), PMEHours, PMEGallons and SMEHours as it they were objects but you have not declared them within your code. I am thinking you may have done that in the long version of your code or, perhaps, they are some kind of control that you inserted on the sheet... cannot tell which based on what you posted.
 
Upvote 0
Usually "shortened versions" of code tend to omit what we need to see. Based on what you posted, I would say all four of your assignment lines would cause that error as you using Day (a terrible name as it is also a built-in VB function name), PMEHours, PMEGallons and SMEHours as it they were objects but you have not declared them within your code. I am thinking you may have done that in the long version of your code or, perhaps, they are some kind of control that you inserted on the sheet... cannot tell which based on what you posted.

I shortened it by removing more of near identical assignment lines. All are setup just like the four there. The Day, PMEHours, etc. refer to textboxes on my userform. When I run the debug it highlights the eRow line as the issue.
 
Upvote 0
I doubt if anyone will be able attempt to answer your question until they can see how Database is defined (at the very least) and so if you want someone to try and find an answer it would be a good idea to post your full code.
 
Upvote 0
Here is the full code. "Database" is the sheet that the information from the textboxes goes to. The Enter_Click() is from the command button in the userform that I created.


Code:
Private Sub Enter_Click()


eRow = Database.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row


Cells(eRow, 1).Value = Day.Text
Cells(eRow, 2).Value = PMEHours.Text
Cells(eRow, 3).Value = PMEGallons.Text
Cells(eRow, 4).Value = SMEHours.Text
Cells(eRow, 5).Value = SMEGallons.Text
Cells(eRow, 6).Value = SGenHours.Text
Cells(eRow, 7).Value = SGenGallons.Text
Cells(eRow, 8).Value = PGenHours.Text
Cells(eRow, 9).Value = PGenGallons.Text
Cells(eRow, 10).Value = EGenHours.Text
Cells(eRow, 11).Value = FBTHours.Text
Cells(eRow, 12).Value = FBTGallons.Text
Cells(eRow, 13).Value = ABTHours.Text
Cells(eRow, 14).Value = ABTGallons.Text
Cells(eRow, 15).Value = STHours.Text
Cells(eRow, 16).Value = STGallons.Text
Cells(eRow, 17).Value = TicketNumbers.Text
Cells(eRow, 18).Value = DTFuel.Text
Cells(eRow, 19).Value = FuelOffload.Text
Cells(eRow, 20).Value = FuelLoad.Text
Cells(eRow, 21).Value = FuelCorrection.Text
Cells(eRow, 23).Value = LOUsed.Text
Cells(eRow, 24).Value = LOAdded.Text
Cells(eRow, 25).Value = LOCorrection.Text
Cells(eRow, 27).Value = GOUsed.Text
Cells(eRow, 28).Value = GOAdded.Text
Cells(eRow, 29).Value = GOCorrection.Text
Cells(eRow, 31).Value = HOUsed.Text
Cells(eRow, 32).Value = HOAdded.Text
Cells(eRow, 33).Value = HOCorrection.Text




End Sub
 
Upvote 0
If that is the full code where are you defining the variable Database? or is it the sheets codename?
If neither of the above and it is the sheets tab name then it should be Sheets("Database").
 
Upvote 0
If that is the full code where are you defining the variable Database? or is it the sheets codename?
If neither of the above and it is the sheets tab name then it should be Sheets("Database").

The code posted is to transfer data entered into text boxes on a VBA userform into a sheet named Database. I called it Database as I need the data entered to recorded and saved every time new data is entered. I just changed the property defined as (Name) in the VBA developer screen for the Database sheet to Database as well. This resulted in a Run-time error '1004': Application-defined or object-defined error.
 
Upvote 0
You are not defining Database anywhere, if it is named database (i.e the name on the sheet tab) then it is

Code:
eRow = Sheets("Database").Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row

not


Code:
eRow = Database.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row

If it is not the name on the sheet tab then it is either a variable and you haven't defined it in the code or it's codename.

Where exactly in the VBE did you change it's name in the properties, there are 2 places?

We are going around in circles here.

http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm
 
Last edited:
Upvote 0
You are not defining Database anywhere, if it is named database (i.e the name on the sheet tab) then it is

Code:
eRow = Sheets("Database").Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row

This resulted in the Run-time error '1004' as well.
 
Last edited:
Upvote 0
In link in my previous post have a look at the picture, then have a look at your VBE editor, find your sheet Database and post what is outside the brackets and what is inside the brackets.

Edit: Maybe also if you change the red 1 in the lines below to a lower case L that it should be we might also get somewhere with one of the lines.

Code:
eRow = Database.Cells(Rows.Count, 1).End(x[COLOR="#FF0000"][B]1[/B][/COLOR]Up).Offset(1, 0).Row

or

Code:
eRow = Sheets("Database").Cells(Rows.Count, 1).End(x[COLOR="#FF0000"][B]1[/B][/COLOR]Up).Offset(1, 0).Row
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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