PC Review


Reply
Thread Tools Rate Thread

deleting unwanted columns in multiple worksheets

 
 
Vikram
Guest
Posts: n/a
 
      22nd Apr 2010
Hello All,
am newbie to excel, i have a workbook which has multiple worksheets and all
these worksheets contains many unwanted columns. i would like to develop a
macro which will keep only the columns that i need in all the worksheet.
Please help me in this regard
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      22nd Apr 2010
What criteria determines if the column is not wanted?


"Vikram" <(E-Mail Removed)> wrote in message
news:FA2E6FA2-3146-4CC9-BA72-(E-Mail Removed)...
> Hello All,
> am newbie to excel, i have a workbook which has multiple worksheets and
> all
> these worksheets contains many unwanted columns. i would like to develop a
> macro which will keep only the columns that i need in all the worksheet.
> Please help me in this regard



 
Reply With Quote
 
Paul Robinson
Guest
Posts: n/a
 
      22nd Apr 2010
Hi
not very elegant but

Sub removecolumns()
Dim ws As Worksheet
Dim columnarray As Variant
Dim arraysize As Integer, i As Integer

Application.ScreenUpdating = False
columnarray = Array(1, 3, 7, 8, 9)
arraysize = UBound(columnarray)

For Each ws In ActiveWorkbook.Worksheets
For i = arraysize To 0 Step -1
ws.Columns(columnarray(i)).Delete
Next i
Next ws
End Sub

Replace your array values with the columns you need to remove.
note: Array is 0 based so counting starts at 0. You run the delete
from right to left or you will delete coulmns you need to keep as
deletion will upset the column number.
regards
Paul

On Apr 22, 6:44*pm, Vikram <Vik...@discussions.microsoft.com> wrote:
> Hello All,
> am newbie to excel, i have a workbook which has multiple worksheets and all
> these worksheets contains many unwanted columns. i would like to develop a
> macro which will keep only the columns that i need in all the worksheet.
> Please help me in this regard


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting rows in multiple worksheets Elizabeth Microsoft Excel Programming 5 11th Nov 2008 12:00 AM
Need Simple List...Multiple Columns and Multiple Worksheets Jane Doe Microsoft Excel Worksheet Functions 6 14th Jul 2008 08:12 PM
linking multiple columns onto multiple worksheets =?Utf-8?B?dGFsZGVybWFu?= Microsoft Excel Misc 3 23rd Aug 2006 02:00 AM
Macros deleting certain worksheets, columns and rows Steezo Microsoft Excel Discussion 0 1st Aug 2005 10:28 AM
Deleting cells in multiple worksheets markstro Microsoft Excel Misc 5 9th Mar 2004 07:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 PM.