![]() |
Activate code when sheet is deleted
Hi,
Is there a way to run code when a worksheet is deleted? Thanks. |
Activate code when sheet is deleted
Karen,
Unfortunately there's no worksheet_delete event but there is a workaround. Alt+f11 - double click This Workbook and paste this in:- Private sheetname As String Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim sheet As Worksheet For Each sheet In Worksheets If sheet.Name = sheetname Then ok = True Exit For End If Next If Not ok Then MsgBox sheetname & " has been deleted" 'Your code goes here End If End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) sheetname = Sh.Name End Sub Mike "Karen53" wrote: Hi, Is there a way to run code when a worksheet is deleted? Thanks. |
All times are GMT +1. The time now is 02:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com