Auto Fill Error

heffo500

New Member
Joined
Sep 28, 2016
Messages
44
Hi

Would someone be able to help why this doesn't work?

VBA Code:
Sub Macro5()
'
' Macro5 Macro
'
Dim LR As Long, LR2 As Long, LR3 As Long, code As String

Sheets("Core Data").Select

LR = Range("B" & Rows.Count).End(xlUp).Row
LR2 = Range("R" & Rows.Count).End(xlUp).Row
LR3 = (Range("R" & Rows.Count).End(xlUp).Row) + 1
code = "R" & LR3 & ":V" & LR

    
    Range("R" & LR2 & ":V" & LR2).Select
    Range("V" & LR2).Activate
    Selection.AutoFill Destination:=Range(code), Type:=xlFillDefault
    Range(code).Select

End Sub

I'm importing data into first empty row in cells A:P and then autofill the formulas from R:V. However I get the following error:
Excel VBA Runtime Error 1004 - "Autofill Method of Range Class Failed”


Any help would be great.

Thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
How about
VBA Code:
Sub heffo()
   Dim Lr As Long
   With Sheets("Core Data")
      Lr = .Range("B" & Rows.Count).End(xlUp).Row
      With .Range("R" & Rows.Count).End(xlUp)
         .Resize(Lr - .Row + 1, 5).FillDown
      End With
   End With
End Sub
 
Upvote 0
You have a lot of code that you don't need, but nothing stands out as the potential cause of your error.

Are any of the formulas in merged cells?
 
Upvote 0
How about
VBA Code:
Sub heffo()
   Dim Lr As Long
   With Sheets("Core Data")
      Lr = .Range("B" & Rows.Count).End(xlUp).Row
      With .Range("R" & Rows.Count).End(xlUp)
         .Resize(Lr - .Row + 1, 5).FillDown
      End With
   End With
End Sub
Thanks a million that work perfectly, I want this to copy down the formula which it does and then afterwards copy all cells and past special over the cell with values that the original formulas returned, what would be the best way to do this?
 
Upvote 0
How about
VBA Code:
Sub heffo()
   Dim LR As Long
   With Sheets("Core Data")
      LR = .Range("B" & Rows.Count).End(xlUp).Row
      With .Range("R" & Rows.Count).End(xlUp)
         .Resize(LR - .Row + 1, 5).FillDown
         .Resize(LR - .Row + 1, 5).Value = .Resize(LR - .Row + 1, 5).Value
      End With
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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