Copy Cell Across Columns

  • Thread starter Thread starter ExcelMonkey
  • Start date Start date
E

ExcelMonkey

I recorded a macro that copies a cell in B1 across to I1:

Selection.AutoFill Destination:=Range("B1:I1")
Type:=xlFillDefaultRange("B1:I1").Select

I effectively copied it across 7 columns. How would I write this s
that I can pass the number 7 to a variable and then uses this t
quantify how many columns across from the start cell I want to cop
from? Assuming start cell is B1.

Thank-yo
 
ExcelMonkey

something like:

x = 7
Range("B1:C1").AutoFill _
Destination:=Range(Cells(1, 2), _
Cells(1, 2 + x)), _
Type:=xlFillDefault

Regards

Trevor
 
Back
Top