ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_Delete event? (https://www.excelbanter.com/excel-programming/323654-worksheet_delete-event.html)

Cool Sport

Worksheet_Delete event?
 
Hi there,

Is there such an event like Worksheet_Delete or Chart_Delete? If there
isnt any, then how do we know when a worksheet or chart sheet is deleted
by user.

Regards,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tim Williams

Worksheet_Delete event?
 
AFAIK there are no events like that. If it's essential for you to
catch these events then you could instead protect the workbook and
provide the user with a button to delete a sheet or chart.

Tim


"Cool Sport" wrote in message
...
Hi there,

Is there such an event like Worksheet_Delete or Chart_Delete? If
there
isnt any, then how do we know when a worksheet or chart sheet is
deleted
by user.

Regards,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Patrick Molloy[_2_]

Worksheet_Delete event?
 
There's a workaround of course. if you record the worksheet that was
deactivated and test for this in the sheet activate event, you can see which
sheet was removed

in ThisWorkbook code page:

Option Explicit
Private WSName As String
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ws As Worksheet
Dim ok As Boolean
For Each ws In Worksheets
If ws.Name = WSName Then
ok = True
Exit For
End If
Next
If Not ok Then
MsgBox WSName & " has been deleted"
End If
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
WSName = Sh.Name
End Sub

a better alternative would be toi keep a list of worksheets, graph sheets
etc, then on a deactivate event, simple look up whats missing.




"Cool Sport" wrote:

Hi there,

Is there such an event like Worksheet_Delete or Chart_Delete? If there
isnt any, then how do we know when a worksheet or chart sheet is deleted
by user.

Regards,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Cool Sport

Worksheet_Delete event?
 
Many thanks for your responses!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

[email protected]

Worksheet_Delete event?
 
1. Make use of the Deactivate event.
2. You may have already kept a current list of Worksheets ; in the
event of Deactivating a worksheet and then it disappears from the list
....... then you know that it's deleted.
3. Look at the archive of this site. It tells plenty ; a treasure trove
indeed.
4. Regards.



All times are GMT +1. The time now is 01:57 PM.

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