ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Cell Across Columns (https://www.excelbanter.com/excel-programming/292864-copy-cell-across-columns.html)

ExcelMonkey[_90_]

Copy Cell Across Columns
 
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

--
Message posted from http://www.ExcelForum.com


Trevor Shuttleworth

Copy Cell Across Columns
 
ExcelMonkey

something like:

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

Regards

Trevor


"ExcelMonkey " wrote in message
...
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 so
that I can pass the number 7 to a variable and then uses this to
quantify how many columns across from the start cell I want to copy
from? Assuming start cell is B1.

Thank-you


---
Message posted from http://www.ExcelForum.com/




ExcelMonkey[_91_]

Copy Cell Across Columns
 
Thanks

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com