Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Prevent User from Deleting a Worksheet

Status
Not open for further replies.

behbeh

Programmer
Mar 10, 2001
48
0
0
US
Hello!
Is there any way I can capture when a user tries to delete a specific worksheet and cancel the delete or display a message stating they cannot delete a specific worksheet?
Thanks!
 

Lock the workbook :)

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 

To expand:

[tt]Tools > Protection...[/tt][ol][li]Lock Worksheet - will "lock" any cells that have the "Locked" property checked in [tt]Format > Cells[/tt].[/li][li]Lock Workbook - will prevent the user from making any structural changes to the entire workbook, while allowing them to make changes to individual cells (unless sheet is locked as well).[/li][/ol]

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Thanks, cLFlaVA!! I tried it programmatically in my module(s) and it worked great. I do have to keep toggling the Protect off and on throughout my app (depending on what I'm doing) but it works great. Thanks! [thumbsup2]
 
Have a look at sheet level protection, using the USERINTERFACEONLY argument - that allows code to run uninterrupted and as though there is no protection - to the user, however, the worksheet appears protected

Rgds, Geoff

Yesterday it worked. Today it is not working. Windows is like that.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top