Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Is there a way to run code when a worksheet is deleted? Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Run Code On Activate | Excel Worksheet Functions | |||
Prevent code in "Sheet Activate" from running when sheet made visible from other macr | Excel Programming | |||
Activate code in cell | Excel Programming | |||
How to activate "New" tab in Dataform through VB Code | Excel Discussion (Misc queries) | |||
Return to Current Sheet in On (sheet activate) event macro | Excel Programming |