PC Review


Reply
Thread Tools Rate Thread

Delete All Columns Except

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      28th Feb 2007
Looking to create a macro that will erase all columns except where the
first cell (row a) contains the name:

Eggs
Cheese
Salad
Pizza

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      28th Feb 2007
Row 1?????

Option Explicit
sub testme()
dim iCol as long
with activesheet
for icol = .cells.specialcells(xlcelltypelastcell).column to 1 step -1
select case lcase(.cells(1,icol))
case is = "eggs","cheese","salad","pizza"
'do nothing, keep it
case else
.columns(icol).delete
end select
next icol
end with
end sub

This assumes that there's nothing else in the cell except those names.


"J.W. Aldridge" wrote:
>
> Looking to create a macro that will erase all columns except where the
> first cell (row a) contains the name:
>
> Eggs
> Cheese
> Salad
> Pizza


--

Dave Peterson
 
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
Re: Delete & Merge Columns,Delete Rows with filter, etc Matthew Herbert Microsoft Excel Programming 0 16th Jul 2009 08:17 PM
delete columns Moh Microsoft Excel Programming 4 14th Dec 2007 04:06 PM
create a macro to delete columns and then border remaining columns =?Utf-8?B?SmFuZTc3Nw==?= Microsoft Excel Programming 1 18th Jul 2007 12:08 AM
merge text from 2 columns into 1 then delete the old 2 columns =?Utf-8?B?c2xlZXBpbmRvZ2c=?= Microsoft Excel Worksheet Functions 4 30th Mar 2006 07:25 PM
Delete Columns Curtill Microsoft Excel Charting 1 28th Feb 2004 02:13 AM


Features
 

Advertising
 

Newsgroups
 


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