+ Reply to Thread
Results 1 to 5 of 5

VBA Worksheet Protection Coding Help

  1. #1
    Registered User
    Join Date
    09-30-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    3

    VBA Worksheet Protection Coding Help

    Hi all,

    I'll admit now, i'm rather stuck!

    I need help with coding to implement the following protection for my workbook;

    Excel Workbook:
    Standard workbook with the Sheet 1 labelled "home" and 2 additional worksheets available

    Actions:
    1. Open WB -> Password prompted, only "home" worksheet visible
    1.1. Enter Admin password -> all worksheets unhidden
    1.2. Enter pw1, pw2 -> only Sheet1, Sheet2 etc. unhidden (1 corresponding worksheet unhidden for every password other than "Admin") in addition to "home" sheet

    2. Incorrect password -> prompted to try again
    2.1. Incorrect password twice -> workbook closes

    3. Exit workbook -> all worksheets bar "home" are (very)hidden

    4. Bonus step: VBA code is password protected

    Conditions:
    1. "home" sheet/tab always visible
    2. "admin" password unlocks all sheets
    3. pw1, pw2 unlock only corresponding worksheets (sheet1, sheet2)
    4. upon closing workbook all tabs bar "home" are very hidden
    5. upon opening workbook, only "home" tab visible, and incorrect password entered twice closes workbook

    I REALLY appreciate any help!

    Many thanks,

    Excelophobe

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: VBA Worksheet Protection Coding Help

    It seems you have done the bulk of the work, listing exactly what you want to happen, so where exactly are you stuck?
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    09-30-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    3

    Re: VBA Worksheet Protection Coding Help

    Problem is i need help writing the code.

    I have used the veryhidden function to hide tabs on closing and created a user form and programmed the command button to open select tabs based on pw. I don't know how to do action 2;

    2. Incorrect password -> prompted to try again
    2.1. Incorrect password twice -> workbook closes

    Nor am i sure if i should be doing the whole thing through the userform or an input box. Does that make any sense?

  4. #4
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: VBA Worksheet Protection Coding Help

    So this should all be fairly simple, but let me know if you have any questions.

    This needs to reside in ThisWorkbook:
    Please Login or Register  to view this content.

    It is all in the attached workbook.
    Workbook Events.xlsm


    You can use this to lock the code:
    http://www.ozgrid.com/VBA/protect-vba-code.htm

  5. #5
    Registered User
    Join Date
    09-30-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    3

    Re: VBA Worksheet Protection Coding Help

    That's great. Thank you very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA coding to move rows from one worksheet to another
    By AlbertaRose in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2014, 12:37 PM
  2. Replies: 1
    Last Post: 11-21-2013, 11:08 AM
  3. coding for changing worksheet name
    By mingali in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2009, 10:24 AM
  4. Worksheet Coding
    By XCESIV in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-24-2006, 10:30 AM
  5. [SOLVED] Worksheet protection is gone and only wokbook protection can be se
    By Eric C. in forum Excel General
    Replies: 4
    Last Post: 05-02-2006, 11:55 AM

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