Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Insert Columns on Every Sheet

Hi All,

If I want to insert a new column A&B on every sheet in the workbook I
thought to run this sub:

Sub INSERT_COLUMNS()
Dim w As Worksheet
For Each w In ActiveWorkbook.Worksheets
Columns("A:B").Insert
Next w
End Sub

What it does:
On the active sheet it inserts 2 columns times the number of sheets in
the workbook.
So, if you have 5 worksheets...it inserts 10 columns on the active
sheet!

I am ashamed ...
What is wrong with the code ... / me?

Sige

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Insert Columns on Every Sheet

Sub INSERT_COLUMNS()
Dim w As Worksheet
For Each w In ActiveWorkbook.Worksheets
w.Columns("A:B").Insert
Next w
End Sub

--
Regards,
Tom Ogilvy

"Sige" wrote in message
ups.com...
Hi All,

If I want to insert a new column A&B on every sheet in the workbook I
thought to run this sub:

Sub INSERT_COLUMNS()
Dim w As Worksheet
For Each w In ActiveWorkbook.Worksheets
Columns("A:B").Insert
Next w
End Sub

What it does:
On the active sheet it inserts 2 columns times the number of sheets in
the workbook.
So, if you have 5 worksheets...it inserts 10 columns on the active
sheet!

I am ashamed ...
What is wrong with the code ... / me?

Sige



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Insert Columns on Every Sheet

The problem is that you haven't qualified the columns

Instead of
Columns("A:B").Insert

You shoud have said w.Columns("A:B").Insert

This will insert two columns on each sheet. If yuou want to install one
column between A and B then you need
w.Columns("A").Insert


"Sige" wrote:

Hi All,

If I want to insert a new column A&B on every sheet in the workbook I
thought to run this sub:

Sub INSERT_COLUMNS()
Dim w As Worksheet
For Each w In ActiveWorkbook.Worksheets
Columns("A:B").Insert
Next w
End Sub

What it does:
On the active sheet it inserts 2 columns times the number of sheets in
the workbook.
So, if you have 5 worksheets...it inserts 10 columns on the active
sheet!

I am ashamed ...
What is wrong with the code ... / me?

Sige


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert Columns on Every Sheet


Make "Columns("A:B").Insert" read "w.Columns("A:B").Insert

--
kralj
-----------------------------------------------------------------------
kraljb's Profile: http://www.excelforum.com/member.php...nfo&userid=995
View this thread: http://www.excelforum.com/showthread.php?threadid=39060

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Insert Columns on Every Sheet


Thx all!
Time for coffee or more sleep.


"NOSPAM" to be removed for direct mailing...

*** Sent via Developersdex http://www.developersdex.com ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference changes when I insert new columns in the source sheet John Bare Excel Discussion (Misc queries) 3 March 24th 10 04:02 PM
2007 excel work sheet will not allow to insert rows or columns David Excel Discussion (Misc queries) 1 January 24th 09 07:30 PM
can't insert a column, can't shift columns off the sheet. Janis Excel Discussion (Misc queries) 4 July 25th 07 07:26 PM
How to Insert Columns in a big Sheet... JV Excel Worksheet Functions 2 March 30th 07 07:42 PM
unable to insert columns in excel, insert- columns (disabled) iam_leearner Excel Discussion (Misc queries) 1 August 13th 06 02:26 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"