+ Reply to Thread
Results 1 to 9 of 9

Locking Worksheets with a Macro

  1. #1
    Forum Contributor dagindi's Avatar
    Join Date
    06-02-2008
    Location
    New York, NY
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    295

    Locking Worksheets with a Macro

    Good morning,

    I found the following code which allows you to lock sheets 1 to 3 with the ActiveX control buttons located on Sheet4.

    Please Login or Register  to view this content.
    I figured out how to change the code so that, lets say I want Sheet1 to stay visible.

    Please Login or Register  to view this content.
    What I cannot figure out is how to recode this so that I can setup the two ActiveX buttons on Sheet1 and it closes whatever sheet after it I want closed.

    I am attaching the a sample spreadsheet I am working with and it has some additional notes on it.

    Thanks!
    Attached Files Attached Files
    Last edited by dagindi; 12-09-2009 at 02:06 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Locking Worksheets with a Macro

    Hello dagindi,

    Here is the code for the second button. It will prompt you for the sheet you want to hide. You can enter either the sheet number or name.

    Macro to be placed in a VBA Module
    Please Login or Register  to view this content.
    Code for the buttons Click Event
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor dagindi's Avatar
    Join Date
    06-02-2008
    Location
    New York, NY
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    295

    Re: Locking Worksheets with a Macro

    Leith,

    Thanks for the recoding.

    I believe I set up the coding per your instructions but it wont execute. I keep getting a syntax error.

    What am I doing wrong?
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Locking Worksheets with a Macro

    Hello dagindi,

    I should have mentioned in my earlier post I don't have Excel 2007. You will need to save the workbook in 2003 format before I can view it.

  5. #5
    Forum Contributor dagindi's Avatar
    Join Date
    06-02-2008
    Location
    New York, NY
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    295

    Re: Locking Worksheets with a Macro

    No worries.

    Here you go!
    Attached Files Attached Files

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Locking Worksheets with a Macro

    Hello dagindi,

    Thanks for the new copy. I got the macros working and they have been added to the attached workbook. Here is the working code.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Contributor dagindi's Avatar
    Join Date
    06-02-2008
    Location
    New York, NY
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    295

    Re: Locking Worksheets with a Macro

    This is working great and I really appreciate it.

    I can't figure out how to remove the password request from the hidesheet function and apply it to the unhideshide function.

    In other words a person would need the password to unhide the hidden sheets.

    Thanks!

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Locking Worksheets with a Macro

    Hello dagindi,

    I changed the macro for the second button to ask for a password. Here is the code. This has been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Contributor dagindi's Avatar
    Join Date
    06-02-2008
    Location
    New York, NY
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    295

    Re: Locking Worksheets with a Macro

    Leith,

    Thank you so much for all your help.

    I was able to take what you provided and I tailored it to my exact needs.

    Here is what I did:

    Please Login or Register  to view this content.
    This allows to lock/hide sheets without the need for password but wont allow another user to open the locked/hidden sheets without the password.

    Again, thank you very much for all your help!!

+ 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