+ Reply to Thread
Results 1 to 8 of 8

How to lock cells with value once the worksheet is activated of opened

  1. #1
    Registered User
    Join Date
    09-04-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    26

    How to lock cells with value once the worksheet is activated of opened

    hi guys,

    I would like to find out on how to create a vba code or data validation to lock the cells with value when i open the worksheet.

    Example: if cell A1=2 A2=2 then it will automatically locked these two cell everytime i open the worksheet.

    Hoping that someone could help me with this.

    Thanks in advance

  2. #2
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: How to lock cells with value once the worksheet is activated of opened

    Try; Paste this to ThisWorkbook. If macro is not enabled then this won't work.
    Please Login or Register  to view this content.
    Last edited by Blokeman; 02-24-2015 at 01:05 AM.
    Please click the * Add Reputation if this helps
    If solved remember to mark Thread as solved

    "I'm glad to help and this is not meant to sound smart, but either you have super-human vision to see all those controls cleared one by one with the code I posted, or your computer is really slow."

  3. #3
    Registered User
    Join Date
    09-04-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: How to lock cells with value once the worksheet is activated of opened

    Hi Blokeman,

    I have tried your code but nothings happened. I can still edit the cell in A1.
    Please advise.

    Edited:
    It works but it also locked the cells without value. what am i supposed to do for this code to locked only cells with value and make the cells without value to be still editable.

    Thanks Blokeman
    Last edited by oct2mine; 02-24-2015 at 01:09 AM.

  4. #4
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: How to lock cells with value once the worksheet is activated of opened

    Amended the code.

  5. #5
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: How to lock cells with value once the worksheet is activated of opened

    Oooops, one more thing you have to unlock all cells.

  6. #6
    Registered User
    Join Date
    09-04-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: How to lock cells with value once the worksheet is activated of opened

    Hi Blokeman,

    I've tried the new code and also unlocked all the cell but what happened is it doesn't locked the all the cells with value. is this code works for you?

    Thanks

  7. #7
    Registered User
    Join Date
    09-04-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: How to lock cells with value once the worksheet is activated of opened

    i figured it out. thanks so much for your help

  8. #8
    Registered User
    Join Date
    09-04-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: How to lock cells with value once the worksheet is activated of opened

    just a follow up question. what if i want A-AF to be included in this code? i tried this one Range("A:AF") but it doesnt work. do i need to repeat the code per column? or is there a way to put it in range like the one that i am trying to do above?

    thanks for your response it really saves my day

+ 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. How to lock cells in a protected worksheet
    By rbs123 in forum Excel General
    Replies: 2
    Last Post: 02-18-2015, 01:09 AM
  2. Lock cells in worksheet after they are changed
    By eherron in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2011, 04:24 PM
  3. Lock Specific cells in a worksheet.
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-02-2009, 11:46 AM
  4. Can I lock cells or do I have to lock the worksheet?
    By jmbtexas in forum Excel General
    Replies: 4
    Last Post: 11-11-2008, 02:26 PM
  5. Can I lock a set of cells in a worksheet?
    By puneetarora_12 in forum Excel General
    Replies: 3
    Last Post: 07-08-2005, 07:05 PM

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