View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default protect a sheet such that it cannot be deleted

Thanks for your help, In my situation.. I take user inputs from sheet1
through a userform, and those user inputs are stored in sheet2. So I need
them to access Sheet1 only and not sheet2. Hence I want sheet2 to be
protected such that it cannot be edited, viewed or deleted by these users but
me.


"Simon Lloyd" wrote:


With a little bit of VBA you can make the sheet xlVeryHidden which means
it cannot be found or unhidden using the toolbar it can only be made
visible via VBA again, however if you protect the worksheet it cannot be
edited (well locked cells cannot) and if you further protect the
workbook structure the sheet cannot be deleted, anyway in a VBA standard
module add and run this (dont forget to change MySheet for your actual
sheet name.

Code:
--------------------

Sub HideMySheet()
Sheets("MySheet").Visible=xlVeryHidden
End Sub

--------------------

*How to add and run a Macro*1. *Copy* the macro above pressing
the keys *CTRL+C*
2. Open your workbook
3. Press the keys *ALT+F11* to open the Visual Basic Editor
4. Press the keys *ALT+I* to activate the *Insert menu*
5. *Press M* to insert a *Standard Module*
6. *Paste* the code by pressing the keys *CTRL+V*
7. Make any custom changes to the macro if needed at this time.
8. *Save the Macro* by pressing the keys *CTRL+S*
9. Press the keys *ALT+Q* to exit the Editor, and return to Excel.

*To Run the Macro...*
To run the macro from Excel, open the workbook, and press *ALT+F8* to
display the *Run Macro Dialog*. Double Click the macro's name to *Run*
it.

sam;418173 Wrote:
Can I protect a sheet such that users cannot delete or edit or view it?

Thanks in Advance



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=116359