ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Capture "after delete" Worksheet (https://www.excelbanter.com/excel-programming/344199-capture-after-delete-worksheet.html)

Rony Boter

Capture "after delete" Worksheet
 
Hello,



I'm trying to capture the event after the Excel user deletes specific
worksheet.

Can it be done?





Any help would be appreciated


--
Best Regars
Rony Boter



Bob Phillips[_6_]

Capture "after delete" Worksheet
 
Hi Rony,

Here is a way.

First add this code to a standard code module

Public shName As String

Sub Deletesheet()
Dim oWS As Object
On Error Resume Next
Set oWS = Sheets(shName)
If oWS Is Nothing Then
MsgBox shName & " has been deleted"
End If
End Sub

and then add this to the ThisWorkbook code module

Private Sub Workbook_SheetDeactivate(ByVal sh As Object)
shName = sh.Name
Application.OnTime Now + TimeSerial(0, 0, 1), "DeleteSheet"
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rony Boter" wrote in message
...
Hello,



I'm trying to capture the event after the Excel user deletes specific
worksheet.

Can it be done?





Any help would be appreciated


--
Best Regars
Rony Boter





Rony Boter

Capture "after delete" Worksheet
 
Many thanks Bob,

It help.

"Bob Phillips" wrote in message
...
Hi Rony,

Here is a way.

First add this code to a standard code module

Public shName As String

Sub Deletesheet()
Dim oWS As Object
On Error Resume Next
Set oWS = Sheets(shName)
If oWS Is Nothing Then
MsgBox shName & " has been deleted"
End If
End Sub

and then add this to the ThisWorkbook code module

Private Sub Workbook_SheetDeactivate(ByVal sh As Object)
shName = sh.Name
Application.OnTime Now + TimeSerial(0, 0, 1), "DeleteSheet"
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rony Boter" wrote in message
...
Hello,



I'm trying to capture the event after the Excel user deletes specific
worksheet.

Can it be done?





Any help would be appreciated


--
Best Regars
Rony Boter












All times are GMT +1. The time now is 12:41 PM.

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