ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Column and insert (https://www.excelbanter.com/excel-programming/288941-copy-column-insert.html)

DENISE

Copy Column and insert
 
I have the following code that inserts a column next to the active column.

Sub AddColumnt()
ActiveCell.Offset(0, 1).EntireColumn.Insert
End Sub

I would like to copy and paste A1:A10 into the new column. What do I need to add to the macro?

Thanks so much!

Trevor Shuttleworth

Copy Column and insert
 
Denise

You don't actually say where you want the range copied to but this amendment
copies it to the cells adjacent to the active cell.

Sub AddColumnt()
ActiveCell.Offset(0, 1).EntireColumn.Insert
Range("A1:A10").Copy ActiveCell.Offset(0, 1)
End Sub

Regards

Trevor


"Denise" wrote in message
...
I have the following code that inserts a column next to the active column.

Sub AddColumnt()
ActiveCell.Offset(0, 1).EntireColumn.Insert
End Sub

I would like to copy and paste A1:A10 into the new column. What do I need

to add to the macro?

Thanks so much!




DENISE

Copy Column and insert
 
Sorry it did get CF but not cell format (borders) or formulas

Trevor Shuttleworth

Copy Column and insert
 
Denise

it's just a copy statement. It should, and does, copy everything. The
formulae will, of course relate to cells relative to where they have been
copied to, so the results may be "wrong".

I have just tested that it copies borders, conditional formatting and
formulae.

Regards

Trevor


"Denise" wrote in message
...
Thanks Trevor this works great. However its not copying the formatting

both the cells and conditional formatting. If does on the other hand pickup
validation.




All times are GMT +1. The time now is 10:02 PM.

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