Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Macro for Deleting Worksheets

Hi Gary,

Thanks for the code but I couldn't figure if it assumed the tab name was the
same as the column name? And I tried it but got a subscript out of range
error which is the same error I got from the code I was trying before, which
follows:

The user selection mechanism is a checkbox located in row 6 (hence the
Value=FALSE) but I'm sure there's a better way.

Sub CommandButton1_Click()
Dim BTN As Button
Set BTN = ActiveSheet.Buttons(Application.Caller)
'deletes unused tabs and confirm delete dialog
Application.DisplayAlerts = False
If Workbooks("Sheet1").Range("d6").Value = False Then
Worksheets(Array("Sheet2", "Sheet10")).Delete
End If
If Workbooks("Sheet1").Range("e6").Value = False Then
Worksheets(Array("Sheet4", "Sheet12")).Delete
End If
If Workbooks("Sheet1").Range("f6").Value = False Then
Worksheets("Sheet6").Delete
End If
If Workbooks("Sheet1").Range("g6").Value = False Then
Worksheets(Array("Sheet3", "Sheet5", "sheet9")).Delete
End If
If Workbooks("Sheet1").Range("i6").Value = False Then
Worksheets("sheet21").Delete
End If
If Workbooks("Sheet1").Range("T6").Value = False Then
Worksheets(Array("Sheet7", "Sheet15", "sheet17", "sheet18")).Delete
End If
End Sub


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
Deleting worksheets David Excel Discussion (Misc queries) 2 January 19th 07 08:19 PM
Deleting pictures from multiple worksheets dford Excel Discussion (Misc queries) 2 December 24th 06 04:43 AM
Deleting blank worksheets Lvenom Excel Worksheet Functions 3 June 15th 06 12:28 AM
Prompt before deleting worksheets? cbrooks421 Excel Discussion (Misc queries) 2 July 20th 05 05:32 AM
Help deleting worksheets Wilhelmutt Excel Discussion (Misc queries) 2 April 19th 05 03:23 AM


All times are GMT +1. The time now is 01:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"