user1525612
user1525612

Reputation: 2014

Autofill from active cell to 26 columns across

I have a cell with a formula. I want to autofill from that cell, to a fixed number of columns across.

I am trying something along the lines of this:

Selection.AutoFill Destination:=Range("RC:RC[+26]"), Type:=xlFillDefault

but can't get it right.

Thanks!

Upvotes: 0

Views: 1301

Answers (2)

Darren Bartrup-Cook
Darren Bartrup-Cook

Reputation: 19847

You could use Resize:

With ThisWorkbook.Worksheets("Sheet1")
    .Range("A2").AutoFill Destination:=.Range("A2").Resize(, 26), Type:=xlFillDefault
End With

This will fill the formula from A2:Z2.

Upvotes: 3

vacip
vacip

Reputation: 5426

Try using Offset inside a Range command:

Selection.AutoFill Destination:=range(activecell, activecell.Offset(0,26)), Type:=xlFillDefault

The RC style is used in formulas, but I have never seen it used inside a Range object.

Upvotes: 0

Related Questions