ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable Macro automatically when a sheet is deleted (https://www.excelbanter.com/excel-programming/321045-disable-macro-automatically-when-sheet-deleted.html)

bayhe

Disable Macro automatically when a sheet is deleted
 
Hi,

I have a worksheet that contains 12 worksheets for different users to fill
in. Each user will delete the other 11 worksheets and there will be an error
message.

Is there any way to solve this problem?

Thank you very much.

Nick Hodge

Disable Macro automatically when a sheet is deleted
 
Your question is a little vague. You are in the programming group so you
could get code to delete the other sheets by assigning it to a toolbar. the
code below will delete all but the active sheet. (No warning is given

Sub DeleteAllButActive()
Dim wksActive As Worksheet, wks As Worksheet
Set wksActive = ActiveSheet
Application.DisplayAlerts = False
For Each wks In ThisWorkbook.Worksheets
If wks.Name < wksActive.Name Then wks.Delete
Next wks
End Sub



--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"bayhe" wrote in message
...
Hi,

I have a worksheet that contains 12 worksheets for different users to fill
in. Each user will delete the other 11 worksheets and there will be an
error
message.

Is there any way to solve this problem?

Thank you very much.





All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com