Excel Autofill Method of Range Class Failed

S

Steve

Trying to Use the Code below to autofill a selection. Error comes up when
executed, code is in a loop in which i is the number of the row.

Set sourceRange = Worksheets("Ref. PGW").Range(Sheets("Ref. PGW").Cells(i -
1, 8), Sheets("Ref. PGW").Cells(i - 1, 10))
Set fillRange = Worksheets("Ref. PGW").Range(Sheets("Ref.
PGW").Cells(i, 8), Sheets("Ref. PGW").Cells(i, 10))
sourceRange.AutoFill Destination:=fillRange, Type:=xlFillDefault

Thanks, Steve
 
B

Bernie Deitrick

Steve,

The autofiill method requires that the Destination Range includes the source range.

But, you could use

SourceRange.Copy FillRange

or

SourceRange.Copy SourceRange.Offset(1,0)

or

sourceRange.AutoFill Destination:=Range(sourceRange,fillRange), Type:=xlFillDefault

HTH,
Bernie
MS Excel MVP
 

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

Top