![]() |
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 |
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 |
All times are GMT +1. The time now is 12:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com