+ Reply to Thread
Results 1 to 5 of 5

Lock/Unlock range cells based on text value in other range cells

  1. #1
    Forum Contributor
    Join Date
    02-12-2013
    Location
    Brussel
    MS-Off Ver
    Excel 2013
    Posts
    134

    Lock/Unlock range cells based on text value in other range cells

    Hi!

    Can somebody help me with a VBA code that can lock cells in some ranges (e.g. E2:E5000,F2:F5000,G3:G5000,L3:L5000,N3:N5000,AA3:AA5000,etc), based on a text value in range B2:B5000 (e.g. "Activity" - selected from a dropbox list). I use Office 2013, and the worksheet is protected with a password (don't know if it matters).

    Thank you so much in advance!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Lock/Unlock range cells based on text value in other range cells

    Copy this code, right-click the sheet tab, select "View Code", and paste the code into the window that appears. You should make sure that column B (at least) is unlocked, and that the "Password" is changed to the actual password - I had to assume that you only wanted the cells on the same row as the value in B to by locked....

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-12-2013
    Location
    Brussel
    MS-Off Ver
    Excel 2013
    Posts
    134

    Re: Lock/Unlock range cells based on text value in other range cells

    Your assumption is correct. That's exactly what I need.

    Testing the code a bit more I noticed that if I change the text value in row B, after I previously selected "Activity", the code doesn't unlock the cells in columns E:G,L:L,N:N,AA:AA. This is quite a problem, because if the user selects by mistake "Activity" and afterwards selects the right text value, he cannot fill in the cells in columns E:G,L:L,N:N,AA:AA anymore.

    Can this flaw be fixed?
    Last edited by boboivan; 02-12-2014 at 03:19 AM.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Lock/Unlock range cells based on text value in other range cells

    Of course

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-12-2013
    Location
    Brussel
    MS-Off Ver
    Excel 2013
    Posts
    134

    Re: Lock/Unlock range cells based on text value in other range cells

    Thank you sir!

    You know what's curious? I've tried today to add in the code exactly the same line as you did.

    Please Login or Register  to view this content.
    Didn't work for me. I have no idea why.

+ 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. Lock and unlock cells based on value
    By Rocky2013 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2016, 04:53 AM
  2. lock/unlock cell based on another cells input
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-21-2013, 03:17 PM
  3. Lock Range of Cells After Text is Entered
    By cshenold in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2012, 01:21 PM
  4. How to lock and unlock a range of cells based on certain cell's value?
    By potato in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-25-2012, 04:34 AM
  5. Lock/Unlock Cells Based on User Type
    By jzeusj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-21-2011, 04:01 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