Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deletes certain columns


Hi, I have 25 columns.
I need to write a macro which goes through each column,
keeps:
1) Billing
2) GM
3) Total
4) Client
5) Project Name

but deletes the rest

I guess its something like this, many thks

sub del()

Dim i As Long
Dim aryTest

aryTest = Array("Billing ", "GM", "Total","Client","Project Name")

For i = 25 To 1 Step -1
If Not IsError(Application.Match(Cells(1, i).Value, aryTest, 0)) Then
'Keep
Else
'Delete
End If
Next i


End Su

--
T De Villier
-----------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...fo&userid=2647
View this thread: http://www.excelforum.com/showthread.php?threadid=56779

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Deletes certain columns

Sub del()
Dim i As Long
Dim aryTest As Variant

aryTest = Array("Billing ", "GM", "Total", "Client", "Project Name")

For i = 25 To 1 Step -1
If IsError(Application.Match(Cells(1, i).Value, aryTest, 0)) Then
Columns(i).Delete
End If
Next i
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"T De Villiers"
wrote in message
Hi, I have 25 columns.
I need to write a macro which goes through each column,
keeps:
1) Billing
2) GM
3) Total
4) Client
5) Project Name
but deletes the rest
I guess its something like this, many thks

sub del()

Dim i As Long
Dim aryTest

aryTest = Array("Billing ", "GM", "Total","Client","Project Name")

For i = 25 To 1 Step -1
If Not IsError(Application.Match(Cells(1, i).Value, aryTest, 0)) Then
'Keep
Else
'Delete
End If
Next i


End Sub
--
T De Villiers

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deletes certain columns


Thanks a lot Ji

--
T De Villier
-----------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...fo&userid=2647
View this thread: http://www.excelforum.com/showthread.php?threadid=56779

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
macro deletes wrong columns Wanna Learn Excel Discussion (Misc queries) 4 October 6th 09 04:34 PM
Macro that deletes every third row....+ ajjag Excel Discussion (Misc queries) 4 June 27th 06 06:03 PM
Macro That Deletes Columns Lilbit Excel Programming 3 January 5th 06 04:20 PM
Name x as y Deletes file Brad Excel Programming 1 October 25th 05 09:18 PM
Repetative Row Deletes scratching my head Excel Discussion (Misc queries) 1 May 30th 05 09:38 PM


All times are GMT +1. The time now is 06:12 PM.

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"