Error on Autofill

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
 
O

OssieMac

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.
 
O

OssieMac

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Autofill Dynamic Range of Cells 2
Dynamic Autofill Error 1
Error 1004 - Autofill 3
Row spec 4
Autofill Error 4
Autofill not working. 3
Type Mismatch Error 8
Object Required error 1

Top