Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Locking Cells Using VB or Formula

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there a way to lock cells using VB based on the value of another cell. Example:

    I have a list for data entry, if the value of the first cell in the row (A2)is equal to the value of the first row (A1) then I want to lock Cells C2 and D2. This will apply for all subsequent rows as data is entered.

    What is the best way of doing this?


    Thanks.

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Denver, CO
    Posts
    1,743
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You may be able to use data validation for this. Go to your cell you want to lock, and choose validation from the data menu. On the setting tab, change the allow drop down to custom. Type in =A2<>A1 under the formula. You can also add custom input and error messages here if you choose.

    Be aware that this will prevent a user from typing in a value if A1=A2, but it will not prevent a user from pasting a value here. If you need something more robust, VBA is needed.

    Good luck.

    On 2002-02-27 07:26, JohnH wrote:
    Is there a way to lock cells using VB based on the value of another cell. Example:

    I have a list for data entry, if the value of the first cell in the row (A2)is equal to the value of the first row (A1) then I want to lock Cells C2 and D2. This will apply for all subsequent rows as data is entered.

    What is the best way of doing this?


    Thanks.
    [ This Message was edited by: IML on 2002-02-27 07:37 ]

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Did you see my reply to your other post ?
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  4. #4
    New Member
    Join Date
    Feb 2002
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-27 07:26, JohnH wrote:
    Is there a way to lock cells using VB based on the value of another cell. Example:

    I have a list for data entry, if the value of the first cell in the row (A2)is equal to the value of the first row (A1) then I want to lock Cells C2 and D2. This will apply for all subsequent rows as data is entered.

    What is the best way of doing this?


    Thanks.
    Thank you both for the reply. The best solution for my purpose is using the Data Validation method.

    Thanks.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •