Dynamic AutoFill Destination

ilcaa

Well-known Member
Joined
May 25, 2005
Messages
686
Currently running a macro with an autofill destination.. Problem is that starting tommorrow the range of the fill will be completely different and each day download will be different from the next... How can I chnage the macro to autofill based on the current range no matter it length?

thanks..

ActiveCell.FormulaR1C1 = "=rankings "
Selection.AutoFill Destination:=Range("J2:J17")
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

aca_041

New Member
Joined
Mar 16, 2005
Messages
37
Try this one.

ActiveCell.FormulaR1C1 = "=rankings "
Selection.AutoFill Destination:=Range("J2:J" & range("A65536").end(xlup).row)

Assuming the last row in Column A is equal to the last row of the file. So you can chage it as needed. (ie B65536, C65536, etc.)
 

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,764
Do you actually need to use autofill?

Dim End_Row As Long
End_Row = Range("J" & Rows.Count).End(xlUp).Row
Range(J2:J" & End_Row).Formula = "=rankings "

By the way, is 'rankings' a defined name containing a formula, or simply a text string. If it's just text, you could simplify this to:
Range(J2:J" & End_Row) = "rankings"
 

Watch MrExcel Video

Forum statistics

Threads
1,128,025
Messages
5,628,196
Members
416,299
Latest member
Kxs00301

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
Top