+ Reply to Thread
Results 1 to 5 of 5

Conditional locking of cell based on another cell

  1. #1
    Forum Contributor
    Join Date
    09-30-2008
    Location
    Eau Claire, WI
    Posts
    184

    Conditional locking of cell based on another cell

    This is for Excel 2007. I simply want to lock cell H20 and make it's value equal to zero if anything other than 0 is entered into H19. And vice versa (make H19 equal to 0 and lock it if anything greater than 0 is entered into H20). So only one cell can hold a value not equal to zero at a time, and the one that is zero needs to be locked.

    Here's what I have so far. It locks H20 based on H19 being > 0, but doesn't do the vice versa part. And it also doesn't make H20 = 0 when it locks it.
    Thanks!

    Please Login or Register  to view this content.
    Last edited by jman0707; 10-08-2008 at 04:47 PM.

  2. #2
    Forum Contributor
    Join Date
    06-14-2008
    Posts
    153
    Hi,

    Try this code
    Please Login or Register  to view this content.
    It looks OK when I tested in Excel 2003.

    FYI, when you protect a worksheet all cells are protected / locked by default. So if you need cells other than H19 and H20 to be unprotected you have to do that explicitly. If you need more info please check this post:

    http://www.exceldigest.com/myblog/20...n-a-worksheet/

    Regards.
    Last edited by se1429; 10-08-2008 at 04:42 AM.
    Welcome to: http://www.exceldigest.com/myblog/
    "Excel help for the rest of us"

  3. #3
    Forum Contributor
    Join Date
    09-30-2008
    Location
    Eau Claire, WI
    Posts
    184
    YES! That works perfect in XL07 as well! Thanks for your help! I'll definitely hold on to this for the future too.

  4. #4
    Forum Contributor
    Join Date
    06-14-2008
    Posts
    153
    Hi,

    In response to your message regarding password:

    To unlock the sheet for the first time you can add this to the worksheet _Activate event:
    Please Login or Register  to view this content.
    Subsequently you can modify the lines in the code to protect the sheet in the macro as follows:
    Please Login or Register  to view this content.
    Of course you will change the password to whatever your actual password is.

    Regards.

  5. #5
    Forum Contributor
    Join Date
    09-30-2008
    Location
    Eau Claire, WI
    Posts
    184
    Works perfect! I just replaced all worksheet.(un)protect with the code you gave me, worked like a charm, thanks!

+ 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. conditional cell based on actions of another cell
    By florischu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-03-2008, 07:29 PM
  2. Conditional Formating with reference to another cell
    By Spencinator in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-25-2008, 05:56 AM
  3. Conditional Formatting a cell which is showing a %
    By dandavis1 in forum Excel General
    Replies: 2
    Last Post: 09-08-2008, 08:03 AM
  4. Conditional Format- Blank cell with formula problem
    By Trappy in forum Excel General
    Replies: 4
    Last Post: 08-20-2007, 09:51 AM
  5. Conditional Formatting based on 3 different cell values (criteria)
    By xlguy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-05-2007, 05:36 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