Run time error '1004' application-defined or object-defined error

DSEIDEN76

New Member
Joined
Oct 8, 2018
Messages
11
I'm getting the run time error at the point of Auto fill code (noted in red below). I've used this code before with no issues. The Range seems to be defined correctly and the last row was defined earlier in the macro.


Sheets("DC_ORDER").Select
Range("G2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]<=RC[10],""ORDER"",""XXX"")"
Range("G2").Select
Selection.AutoFill Destination:=Range("G2:G" & Cells(Rows.Count, "A").End(x1Up).Row)


With ActiveSheet

LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:AN" & LastRow).Select
End With
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
just use

Code:
Sheets("DC_ORDER").Range("G2:G" & Sheets("DC_ORDER").Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=IF(D2<=Q2,""ORDER"",""XXX"")"

no need to select the sheet OR the range !!
 
Upvote 0
Hi DESEIDEN76,

Welcome to MrExcel!!

Just for reference the number one (bolded) in this line of code...

Code:
Selection.AutoFill Destination:=Range("G2:G" & Cells(Rows.Count, "A").End(x[B]1[/B]Up).Row)

...needs to be a l as in Excel:

Code:
Selection.AutoFill Destination:=Range("G2:G" & Cells(Rows.Count, "A").End(x[B]l[/B]Up).Row)

That said, Michael's nifty one-liner is the way to go IMO.

HTH

Robert
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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