+ Reply to Thread
Results 1 to 18 of 18

Protect sheet from viewing

  1. #1
    Registered User
    Join Date
    01-24-2007
    Location
    Melbourne, Australia
    Posts
    79

    Protect sheet from viewing

    I have a Workbook with 2 sheets, the first one is the data entry and the second one contains all the calculations and confidential info.
    I have one staff member that does the data entry but I don't want them to see the 2nd sheet. I know I can hide the sheet then protect the entire workbook which does work, but is there an easier way so that the second person doesn't have to keep hiding/unhiding the 2nd sheet?
    It would be perfect if when you tried to click on Sheet2, it asked for a password.
    Cheers
    Jase

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Protect sheet from viewing

    Check out this example, it is VBA driven so Macros need to be enabled
    Use the Key
    Ctrl & Shift & U To open the input box,
    enter 123 and Sheet2 will unhide, click the button to hide the sheet again
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    01-24-2007
    Location
    Melbourne, Australia
    Posts
    79

    Re: Protect sheet from viewing

    Thanks Dave, that works, do you know if there is an easier way in Excel 2010?
    Cheers
    Jase

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Protect sheet from viewing

    Sorry, I have not used xl'10

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Protect sheet from viewing

    Here's a simple technique that works like you suggested, it asks for a password when you click on Sheet2. If the wrong password is entered, it takes you back to sheet1.
    Please Login or Register  to view this content.

    ========
    How/Where to install the macro:

    1. Open up your workbook
    2. Right-click the sheet2 tab and select View Code
    3. Copy and Paste in your code (given above)
    4. Edit the macro to the correct password you want, the string is near the top
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook


    Now switch to sheet1, then back to sheet2...
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Registered User
    Join Date
    01-24-2007
    Location
    Melbourne, Australia
    Posts
    79

    Re: Protect sheet from viewing

    Awesome! thanks for that, it worked perfectly.
    Cheers
    Jase

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Protect sheet from viewing

    It's not secure though,if the sheet isn't hidden then if macros aren't enabled anyone can access the sheet. A better way would be to have the sheet hidden and a password on opening would determine which sheets can be visible

    PASSWORD FORM4.zip
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Protect sheet from viewing

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  9. #9
    Registered User
    Join Date
    01-22-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Protect sheet from viewing

    This worked for password protecting the sheet however if someone enters a wrong password, it gives the option of Debug & upon pressing debug...it takes to the code in which the password is visible. Is there a solution to it?

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Protect sheet from viewing

    nachiketjoshi,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  11. #11
    Registered User
    Join Date
    07-31-2015
    Location
    Kamloops, Canada
    MS-Off Ver
    2010
    Posts
    1

    Re: Protect sheet from viewing

    Quote Originally Posted by arlu1201 View Post
    nachiketjoshi,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    So, for everyone who went through this thread and needed it, I think nachiketjoshi had a relevant issue and the answer is this: go into the visual basic formula he is referring to and change sheet name from "sheet1" to the name of the sheet you consider safe in the workbook for everyone to view.

  12. #12
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Protect sheet from viewing

    Quote Originally Posted by DWC Finance View Post
    So, for everyone who went through this thread and needed it, I think nachiketjoshi had a relevant issue and the answer is this: go into the visual basic formula he is referring to and change sheet name from "sheet1" to the name of the sheet you consider safe in the workbook for everyone to view.
    I assume the question is referring to JBeaucaire's code.

    nachiketjoshi did not mention the sheet name had been changed, but that is a good assumption.

  13. #13
    Forum Contributor
    Join Date
    09-10-2010
    Location
    europe
    MS-Off Ver
    Excel 2007
    Posts
    149

    Re: Protect sheet from viewing

    Quote Originally Posted by royUK View Post
    A better way would be to have the sheet hidden and a password on opening would determine which sheets can be visible
    PASSWORD FORM4.zip
    I can't download this file?

    Can someone to set here file for download

  14. #14
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Protect sheet from viewing

    Quote Originally Posted by Dumy View Post
    I can't download this file?

    Can someone to set here file for download
    royUK had used a 3rd party file sharing site, here is his file.
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    09-10-2010
    Location
    europe
    MS-Off Ver
    Excel 2007
    Posts
    149

    Re: Protect sheet from viewing

    Quote Originally Posted by davesexcel View Post
    royUK had used a 3rd party file sharing site, here is his file.
    Thank very much davesexcel

  16. #16
    Registered User
    Join Date
    10-05-2016
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    2

    Re: Protect sheet from viewing

    Quote Originally Posted by davesexcel View Post
    royUK had used a 3rd party file sharing site, here is his file.
    Thanks Dave. I am trying to understand the code, how do you create multiple sheets and password protect them by modifying the form? I can't figure out the password for the Users. Thank you!

  17. #17
    Registered User
    Join Date
    08-28-2018
    Location
    singapore
    MS-Off Ver
    2016
    Posts
    5

    Re: Protect sheet from viewing

    hi may i know the password to the file?

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,345

    Re: Protect sheet from viewing

    Look at the code in post #5.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1