Error on Autofill

  • Thread starter Thread starter Wally
  • Start date Start date
W

Wally

With Worksheets("Data")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("J3:T3").AutoFill Destination:=.Range("J7:T" & LastRow)
_
, Type:=xlFillDefault
End With

I'm receiving Run-time error '1004'
AutoFill method of Range class failed

This works perfectly fine on another worksheet and different range.

TIA
Gerry
 
Hi Wally,

You are missing the dot in front of Rows.Count in the line assigning the row
number to LastRow. However, and I think the main problem is that the AutoFill
Destination range should start at J3 not J7.

With Worksheets("Data")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("J3:T3").AutoFill Destination:= _
.Range("J3:T" & LastRow), Type:=xlFillDefault
End With

Note that the missing dot in front of rows.count will not normally affect
the outcome when getting the total rows in a worksheet but if you were using
assigned ranges then it will and it is good practice to get into the habit of
using it and ensure that it is referencing the With reference.
 
Just an afterthought Wally,

If you do want the destination to commence at cell J7 then I think that you
will have to use copy and paste.
 
Back
Top