Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default deleting unwanted columns in multiple worksheets

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default deleting unwanted columns in multiple worksheets

What criteria determines if the column is not wanted?


"Vikram" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default deleting unwanted columns in multiple worksheets

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 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
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
Deleting multiple columns in excel that are not in a row jriemens1 Excel Discussion (Misc queries) 2 July 15th 09 09:14 PM
Deleting rows in multiple worksheets Elizabeth Excel Programming 5 November 11th 08 12:00 AM
Deleting pictures from multiple worksheets dford Excel Discussion (Misc queries) 2 December 24th 06 04:43 AM
Deleting a rows from multiple worksheets School Teacher Excel Worksheet Functions 0 July 6th 05 06:52 PM
Deleting multiple columns slowdown Scott Timmins Excel Programming 0 July 14th 03 10:58 AM


All times are GMT +1. The time now is 11:16 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"