ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add a Column Macro (https://www.excelbanter.com/excel-programming/288543-re-add-column-macro.html)

Beto[_3_]

Add a Column Macro
 
Randy wrote:

I am looking for a macro that will add a column to the rigght of the active cell/clomn.
All help would be greatly appreciated


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

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.


Beto[_3_]

Add a Column Macro
 
Randy wrote:

Thanks! One thing I forgot to add...I need to copy contents of cells 15:24 of active column to the new column


Sub AddColumnToRightAndCopy()
ActiveCell.Offset(0, 1).EntireColumn.Insert
Range(Cells(15, ActiveCell.Column + 1), _
Cells(24, ActiveCell.Column + 1)).Value = _
Range(Cells(15, ActiveCell.Column), Cells(24, _
ActiveCell.Column)).Value
End Sub

There may be a less cumbersome way to reference the ranges, but this is
what I came up with in such short notice :)

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.



All times are GMT +1. The time now is 07:24 PM.

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