![]() |
Need help for closing the active worksheet only under conditions
Hallo,
i am looking for a VBA-Sub (or hints) to close the active worksheet (containes my vba-project) as the least worksheet. If the active worksheet is not the only opened worksheet, "close" should not work or better should not shown within the system menu of the worksheet window ... Please help me, it is very urgend for me to solve this problem! -- Frank |
Need help for closing the active worksheet only under conditions
Hi Frank
not totally foolproof but give it a try: Put the following in your workbook module: Private Sub Workbook_BeforeClose(Cancel As Boolean) if Application.Workbooks.Count 1 then MsgBox "There are still " & Application.Workbooks.Count & " open. Closing is cancelled" Cancel = True end if End Sub -- Regards Frank Kabel Frankfurt, Germany Frank Petschke wrote: Hallo, i am looking for a VBA-Sub (or hints) to close the active worksheet (containes my vba-project) as the least worksheet. If the active worksheet is not the only opened worksheet, "close" should not work or better should not shown within the system menu of the worksheet window ... Please help me, it is very urgend for me to solve this problem! |
All times are GMT +1. The time now is 01:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com