+ Reply to Thread
Results 1 to 7 of 7

Protect Sheet & Password Protect Code

  1. #1
    Registered User
    Join Date
    05-06-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    42

    Protect Sheet & Password Protect Code

    I have two basic questions.

    1) I need to have code to protect the sheet that my user form is writing to. In other words, when the information from the user form is populated to the sheet, I want that sheet protected by a password that I set where I can unlock it, but no one else can.

    2) I need to protect my VBA code with a password, I do not know how to do this, I have looked everywhere. I do however think this is something simple and I will kick myself once I find out where it is.

    I will attach my workbook to this post so anyone can reference it.
    Attached Files Attached Files
    Last edited by KLahvic; 05-28-2009 at 02:58 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Protect Sheet & Password Protect Code

    1) See VBE Help for the Protect and Unprotect methods

    2) From the VBE, Tools, VBAProject Properties, Protection tab
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-06-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Protect Sheet & Password Protect Code

    shg -

    Thank you for the quick reply.

    Regarding the sheet protection, I know how to manually set it up, but when I do so and go to use my form to enter data it tells me I cannot write to a locked sheet to unlock before continuing. I would like some code to lock the sheet before save event on Finished Click and to unlock sheet when workbook is opened. Is there any way to do this?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Protect Sheet & Password Protect Code

    You need to open the VBE and look at Help there, not from Excel.

  5. #5
    Registered User
    Join Date
    12-29-2005
    Posts
    90

    Re: Protect Sheet & Password Protect Code

    i use this, which is inserted into the workbook object in vba, works brilliantly and will only allow users to change the areas of the sheet that you specifically unprotect through "menu - format, cells,protection tab". it will password protect the whole workbook, only downside i've found is that to change anything you need the password for every sheet individually


    Please Login or Register  to view this content.
    Last edited by jimb0693; 05-13-2009 at 04:08 PM. Reason: code tags added

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Protect Sheet & Password Protect Code

    jimbo,

    Please edit your post to add code tags.

  7. #7
    Registered User
    Join Date
    12-29-2005
    Posts
    90

    Re: Protect Sheet & Password Protect Code

    whoops sorry now sorted

+ 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