Autofill Macro Error

ruci1225

New Member
Joined
Mar 11, 2011
Messages
15
I am creating a macro to perform a min function and am trying to autofill the formula to the end of the row where there is data populated.
The issue is that the number of rows will change daily when new data is imported in.

Currently, I am recieving the following error.

Run-Time Error 1004
Autofill Method of Range Class Failed

Selection.FormulaArray = _
"=MIN(IF('I3'!R1C10:R60000C10=RC[-2],IF('I3'!R1C11:R60000C11>=RC[-1],'I3'!R1C11:R60000C11)))"
Selection.AutoFill Destination:=Range("$AT$1:$AT$6799")

The last line is highlighted.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
This works.

Range("AT1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormulaArray = _
"=MIN(IF('I3'!R1C10:R60000C10=RC[-2],IF('I3'!R1C11:R60000C11>=RC[-1],'I3'!R1C11:R60000C11)))"
 
Upvote 0
When I do this, my results are always 0 for every row as it takes the exact formula and pastes it. It has Ar2 and As2 for every row when I highlight any cell to view the formula. It should change depending on the row as there are no $.

I appreciate yuor help
 
Upvote 0
Sorry my bad,

This will work better. :)

HTML:
Sub autOfiLLformula()

Dim LastRow As Long
LastRow = Cells(Rows.Count, "At").End(xlUp).Row

'you can change "at" above to another column if you want to reference the used range of that column"

Range("at1").Formula = "=MIN(IF('I3'!R1C10:R60000C10=RC[-2],IF('I3'!R1C11:R60000C11>=RC[-1],'I3'!R1C11:R60000C11)))"

Range("AT1").AutoFill Destination:=Range("AT1:AT" & LastRow)

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,678
Members
452,937
Latest member
Bhg1984

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