Reputation: 700
I am trying to autofill to the next column along, I set the ranges, I checked them and they are selected using .Select
but when I run the code it bugs out saying "AutoFill method of Range class failed"
LastRow = [C65000].End(xlUp).Row
LastColumn = [IV5].End(xlToLeft).Column
Set AutoFillSource = Range(Cells(5, LastColumn), Cells(LastRow, LastColumn))
Set AutoFillRangeTo = Range(Cells(5, LastColumn + 1), Cells(LastRow, LastColumn + 1))
AutoFillSource.AutoFill Destination:=AutoFillRangeTo
I have looked at this SO answer but it doesnt resolve it, I also looked at msdn to see if I missed anything but also came up empty
Upvotes: 0
Views: 97
Reputation: 380
The target range has to include the source range. Use:
Set AutoFillRangeTo = Range(Cells(5, LastColumn), Cells(LastRow, LastColumn + 1))
Upvotes: 2