PC Review


Reply
Thread Tools Rate Thread

Activate code when sheet is deleted

 
 
=?Utf-8?B?S2FyZW41Mw==?=
Guest
Posts: n/a
 
      6th Sep 2007
Hi,

Is there a way to run code when a worksheet is deleted?

Thanks.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      6th Sep 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activate sheet in another workbook by its code name AshMorK Microsoft Excel Programming 2 27th Sep 2008 04:21 AM
Run Code on Activate Sheet Theresa Microsoft Excel Programming 6 18th Dec 2007 03:33 AM
Prevent code in "Sheet Activate" from running when sheet made visible from other macr Simon Lloyd Microsoft Excel Programming 10 21st Jun 2006 09:15 AM
Run a sheet's activate code when entering it's workbook mikeburg Microsoft Excel Programming 2 3rd Dec 2005 05:50 AM
Why wouldn't calling the Activate sub for a sheet automatically call that sheet's Worksheet_Activate() sub? Scott Lyon Microsoft Excel Programming 3 19th Aug 2003 03:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:02 PM.