Deleting tabs in Excel
Hi -
I have an Excel workbook with several tabs titled with #'s (Ex: 100, 205, 303, 544, etc.) Is it possible to create a macro that will delete all the tabs except for a certain group? For example, I would want to keep tab 205 and 303 but delete all the other ones. Thanks Stephen |
Deleting tabs in Excel
for each ws in worksheets
if ws.name<"nameone" and ws.name<"name2" then ws.delete next -- Don Guillett SalesAid Software wrote in message oups.com... Hi - I have an Excel workbook with several tabs titled with #'s (Ex: 100, 205, 303, 544, etc.) Is it possible to create a macro that will delete all the tabs except for a certain group? For example, I would want to keep tab 205 and 303 but delete all the other ones. Thanks Stephen |
Deleting tabs in Excel
You may want to look at the "select case" example in VBA's Help:
Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets Select Case LCase(wks.Name) Case Is = "205", "303", "keepthis" 'do nothing Case Else Application.DisplayAlerts = False wks.Delete Application.DisplayAlerts = True End Select Next wks You always have to have at least one visible sheet in the workbook--this code didn't do any checking for that. wrote: Hi - I have an Excel workbook with several tabs titled with #'s (Ex: 100, 205, 303, 544, etc.) Is it possible to create a macro that will delete all the tabs except for a certain group? For example, I would want to keep tab 205 and 303 but delete all the other ones. Thanks Stephen -- Dave Peterson |
All times are GMT +1. The time now is 01:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com