ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how to create a macro that references the currently active cell (https://www.excelbanter.com/excel-worksheet-functions/122580-how-create-macro-references-currently-active-cell.html)

Kurt

how to create a macro that references the currently active cell
 
I would like to create a macro that will insert 5 columns to the right of the
currently active cell. I would like to select any cell in my worksheet and
run the macro and have it insert 5 columns. Any ideas?

Bob Phillips

how to create a macro that references the currently active cell
 
Activecell.Offset(0,1).Resize(1,5).EntireColumn.In sert

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Kurt" wrote in message
...
I would like to create a macro that will insert 5 columns to the right of
the
currently active cell. I would like to select any cell in my worksheet and
run the macro and have it insert 5 columns. Any ideas?




Jim Thomlinson

how to create a macro that references the currently active cell
 
Give this a whirl...

Sub Insert5Columns()
ActiveCell.Offset(0, 1).Resize(, 5).EntireColumn.Insert
End Sub
--
HTH...

Jim Thomlinson


"Kurt" wrote:

I would like to create a macro that will insert 5 columns to the right of the
currently active cell. I would like to select any cell in my worksheet and
run the macro and have it insert 5 columns. Any ideas?



All times are GMT +1. The time now is 01:40 PM.

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