+ Reply to Thread
Results 1 to 6 of 6

VBA Code to unlock cells on a protected sheet based on cell value in another worksheet

  1. #1
    Registered User
    Join Date
    11-12-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    4

    VBA Code to unlock cells on a protected sheet based on cell value in another worksheet

    Hi,

    Needless to say, I am new to excel VBA and grappling with a problem. I have referred a lot of posts on similar topics, but none seem to help in my case. This is what I have -

    I have 2 worksheets - Sheet 1 and Sheet 2. Sheet 2 is protected. What I want to do is,If value in Sheet 1, cell C20 is 0 (or blank), then I want to unlock range G10:P13 in sheet 2. If however, user enters a value in sheet 1 cell C20, then I want to keep sheet 2 range G10:P13 locked (i.e. entire sheet 2 locked)

    Would appreciate your help!

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: VBA Code to unlock cells on a protected sheet based on cell value in another worksheet

    Welcome to the forum!

    I normally use the protection code in the ThisWorkbook object's Open event. Change ken to suite.

    Right click sheet1's tab, View Code, and paste.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-12-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    4

    Re: VBA Code to unlock cells on a protected sheet based on cell value in another worksheet

    Hello Ken,
    Many thanks for the reply. Just to clarify a couple of questions -
    1. Should I post this code in the sheet 1 or sheet 2?
    2. I assume Ken is the password, and I can change it to any other.

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: VBA Code to unlock cells on a protected sheet based on cell value in another worksheet

    1.
    Right click sheet1's tab, View Code, and paste.
    2.
    Change "ken" to suite.
    Note: "ken" <> "Ken".

  5. #5
    Registered User
    Join Date
    11-12-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    4

    Re: VBA Code to unlock cells on a protected sheet based on cell value in another worksheet

    Hi Ken,

    I tried the code you mentioned and got an error message -
    Run time error '9':
    Subscript out of range.

    What should I do?

  6. #6
    Registered User
    Join Date
    11-12-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    4

    Re: VBA Code to unlock cells on a protected sheet based on cell value in another worksheet

    Hi Ken - No worries. I found a fix. The worksheet works perfect!! Thanks so much for your help with the code.

+ 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. Replies: 7
    Last Post: 08-06-2013, 02:23 PM
  2. Conditionally unlock worksheet based on cell input in worksheet
    By CST in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2013, 10:27 AM
  3. [SOLVED] How do I unlock a protected worksheet:password protected
    By Terry Swift in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-01-2005, 09:05 PM

Tags for this Thread

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