Assigning Macro Problem

M

mai

Hi, I'm trying to assign my macro to an action or event (I think I'
using the correct jargon).

When my user goes in to delete a worksheet, I want to call m
'DeleteSheet' subroutine.

So I would have something like:

Private Sub Workbook_Activate()

If ActiveWorkSheet.Delete then Call DeleteSheet
End If

End Sub

Will this macro always run in the background or can I specify it to ru
only when user tries to delete?

Thanks
 
J

Jim Rech

There is no delete sheet event. If you want to trap the user deleting a
worksheet I'd suggest that you protect the workbook so that he cannot
directly do a sheet delete, and then provide a macro, attached to a menu,
toolbutton, etc., that does the delete.

--
Jim Rech
Excel MVP
| Hi, I'm trying to assign my macro to an action or event (I think I'm
| using the correct jargon).
|
| When my user goes in to delete a worksheet, I want to call my
| 'DeleteSheet' subroutine.
|
| So I would have something like:
|
| Private Sub Workbook_Activate()
|
| If ActiveWorkSheet.Delete then Call DeleteSheet
| End If
|
| End Sub
|
| Will this macro always run in the background or can I specify it to run
| only when user tries to delete?
|
| Thanks.
|
|
| ---
|
|
 
M

Myrna Larson

You mean create a new event that fires when a worksheet is delete? No, there's
no way to do this.
 
M

mai

Darn, I thought Excel could do EVERYTHING! Oh well. Thanks fo
responding! I really appreciate it
 
Top