Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Delete All Columns Except

Looking to create a macro that will erase all columns except where the
first cell (row a) contains the name:

Eggs
Cheese
Salad
Pizza

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Delete All Columns Except

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
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
delete columns if 0 jatman New Users to Excel 2 January 3rd 09 04:39 AM
Delete Columns Bernie New Users to Excel 1 February 28th 07 10:15 PM
merge text from 2 columns into 1 then delete the old 2 columns sleepindogg Excel Worksheet Functions 4 March 30th 06 07:25 PM
Can't delete columns Buss Excel Discussion (Misc queries) 3 December 16th 05 07:28 PM
Delete columns Scottmk[_32_] Excel Programming 8 September 3rd 04 01:11 AM


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