ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting blank columns (https://www.excelbanter.com/excel-programming/304411-inserting-blank-columns.html)

poppy

Inserting blank columns
 
Hi again

I am trying to insert a column into an excel sheet. Using VBA it read
like this:

'shift cells to right
Range("E:E,H:H,K:K,N:N,Q:Q,T:T,W:W,Z:Z,AC:AC,AF:AF ,AI:AI").Select
Selection.Insert Shift:=xlToRight

I am trying to do this in VB this way. I am not sure of the syntax

For i = 2 To 31 Step 4
Selection.Insert Shift:=xlToRight
Next

Any one with the equivalent in VB would be appreciated

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


nath

Inserting blank columns
 

-----Original Message-----
Hi again

I am trying to insert a column into an excel sheet. Using

VBA it reads
like this:

'shift cells to right
Range

("E:E,H:H,K:K,N:N,Q:Q,T:T,W:W,Z:Z,AC:AC,AF:AF,AI:A I").Selec
t
Selection.Insert Shift:=xlToRight

I am trying to do this in VB this way. I am not sure of

the syntax

For i = 2 To 31 Step 4
Selection.Insert Shift:=xlToRight
Next

Any one with the equivalent in VB would be appreciated.


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

almost there, you just need to add activesheet.columns

(i).select, before your line which begins selection.


poppy

Inserting blank columns
 
Hi Nath

Thanx for your help my code is working fine.


Kind Regard

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



All times are GMT +1. The time now is 06:17 AM.

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