Is there anyway to prevent certain sheets from be deleted?
i know there is protect workbook, but that prevents the user from deleting any sheet
Is there anyway to prevent certain sheets from be deleted?
i know there is protect workbook, but that prevents the user from deleting any sheet
See if example helps
Code used
In sheet1 module (right click sheet1 rab > select view code)
Please Login or Register to view this content.
Code in a normal modulePlease Login or Register to view this content.
VBA NoobPlease Login or Register to view this content.
Last edited by VBA Noob; 12-19-2007 at 04:14 PM.
_________________________________________
Credo Elvem ipsum etian vivere
_________________________________________
A message for cross posters
Please remember to wrap code.
Forum Rules
Please add to your signature if you found this link helpful. Excel links !!!
awesome, thanks man!
so uh how do i turn it off? lol
i ran it on a sheet i do want to be able to delete and can't figure it out ha
Code is triggered when you select or unselected sheet1. Unselect sheet1 to turn off
VBA Noob
so uh, i tried making a new workbook entirely, and the macro followed it there
for example, lets say i select sheet3, and then right click to try and delete, it pops open the excel with the preventdelete macro and doesn't allow me to do even if i disable macros
Shouldn't work like that. Is it my example or your workbook
VBA Noob
well i had my workbook open
and then i open your example, ran the macro
and now it seems to have applied itself to ever other workbook lol
Yes. As Sheet1 was still active in my example when you switched to the other workbook it would still be on.
Try adding this code to thisworkbook module
VBA NoobPlease Login or Register to view this content.
OOOOOO okay
i get it now
in my other workbook i didn't have sheet 1 active but things still wouldn't delete and i was mad confused lol
so in your code, where is it decide that if its sheet1 is active you can't delete
because i want to try and edit your code so that it doesn't have to be sheet1, it could be for specific sheets that i don't one deleted
like sheets 2, 3 and 7
it'll be different for every user using my excel template
The code goes in the sheet module and is activated when you select the sheet. So if you add the code to say Sheet 1 and sheet 2 it will call the delete macro message and stop the user deleting either of those sheets
VBA Noob
jubi23,
Please read forum rules below and the message to cross posters then add the link to the cross post.
VBA Noob
ah okay, sorry about cross posting!
never really thought about
thanks again for all your help
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks