LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Delete Sheet event?

I believe you could combine the Workbook_SheetDeactivate and
Workbook_SheetActivate event handlers to accomplish this. Try this code in
the ThisWorkbook module of your project. The Deactivate event is triggered
before the sheet is deleted and saves the sheet name to a variable. The
Activate event is triggered after the sheet is deleted, which tests for the
existence of the previous active sheet.


Dim strLastSheet As String

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim wksTemp As Worksheet

On Error Resume Next
Set wksTemp = Worksheets(strLastSheet)
If wksTemp Is Nothing Then MsgBox "Sheet Deleted"

End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
strLastSheet = Sh.Name
End Sub

"Dev" wrote:

Is there a way to see if user selects "Delete Sheet"?

I am trying to delete custom doc properties attached to that sheet when user
delete a sheet - how do I trigger this event? I don't see any ID number for
"Delete Sheet"

Thanks for any suggesstion...

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Chart Event El vengador de la capa Charts and Charting in Excel 3 December 13th 08 11:32 AM
How to trap delete row event and hide column event? Alan Excel Programming 3 April 26th 05 04:25 PM
Return to Current Sheet in On (sheet activate) event macro Paul Moles Excel Programming 1 March 27th 05 03:16 PM
How do I 'catch' a 'delete cells' event Eric Excel Discussion (Misc queries) 2 March 9th 05 07:22 PM
Assign values to a cell in sheet A, from worksheet_change event of sheet B Arif Khan Excel Programming 1 May 4th 04 04:51 AM


All times are GMT +1. The time now is 07:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"