AutoFill Method of Range Class Failed

Felix_Dragonhammer

Board Regular
Joined
Apr 7, 2015
Messages
117
So basically the title says it all. I'm getting an error message on a bit of code as follows:

Code:
'
'SKU Tracking Sheet Update
'
Sheets("SKU Tracking Sheet").Select
Range("Y2") = Range("Y2") + 1
ColToRef2 = Range("Y2").Value
ColToRef3 = Range("Z2").Value
    For n = 7 To 183 Step 22
        Cells(n, ColToRef).Select
        Selection.AutoFill Destination:=Range(Cells(n, ColToRef2), Cells(n, ColToRef3)), Type:=xlFillDefault
    Next n
Cells(249, ColToRef).Select
Selection.AutoFill Destination:=Range(Cells(249, ColToRef2), Cells(249, ColToRef3)), Type:=xlFillDefault

The line in question is:
Code:
Selection.AutoFill Destination:=Range(Cells(n, ColToRef2), Cells(n, ColToRef3)), Type:=xlFillDefault

If necessary, I can provide the entire code that it's in. Thanks in advance for any help I get!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
The destination argument in autofill must include the source range. If ColToRef is not equal to ColToRef2, that's not the case for the code you posted.
 
Upvote 0

Forum statistics

Threads
1,196,516
Messages
6,015,664
Members
441,914
Latest member
VBAllTheThings

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