Assigning Macro Problem

  • Thread starter Thread starter mai
  • Start date Start date
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
 
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.
|
|
| ---
| Message posted
|
 
You mean create a new event that fires when a worksheet is delete? No, there's
no way to do this.
 
Darn, I thought Excel could do EVERYTHING! Oh well. Thanks fo
responding! I really appreciate it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top