View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default 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.