Re: Prevent sheet deletion
Hi, Mike. If you're looking to loop through all sheets and perform the same operation on each, you can use the For Each construct:
Public Sub test() Dim wb As Workbook, ws As Worksheet Set wb = ThisWorkbook For Each ws In wb.Worksheets 'run code MsgBox ws.Name Next ws Set ws = Nothing Set wb = Nothing End Sub
For example, this procedure will display the name of each worksheet, one after another, till all have been displayed.
If the operation differs for each sheet, you can add a Select Case statement inside the loop that picks the correct operation.
If this works for you, you won't need to have the End sheet. However, if you do want to use a hidden worksheet in code, you can set that worksheet's Visible property to xlSheetVisible before beginning to use it, and then to xlSheetVeryHidden once the code using it is finished. This will make it accessible to you without the user ever knowing it's there.
Hope this helps.