+ Reply to Thread
Results 1 to 11 of 11

macro that locks down cells based on a what is shown in another cell

  1. #1
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269

    macro that locks down cells based on a what is shown in another cell

    Hi,

    I have a workbook with several sheets, but just on the sheet called “sales” I need a macro to do the following:

    If F4 = CST
    Then Lock down H4-S4 and AM4-AZ4

    But if F4 is changed to something else I need H4-S4 and AM4-AZ4 to be unlocked

    Is a password necessary for this? It is ou

    I just want it to lock and unlock, not protect and unprotect.

    Thanks for any help.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Right-click on the worksheet tab, View Code and paste this code:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    U can add the Ucase statement to allow for upper and lower case entry to StephenR code.


    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Humm, neither of these are working. I have this running in "this workbook" could that be messing it up for me?

    Please Login or Register  to view this content.
    Thanks again

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    caliskier,

    The sheet is protect. Try this. I've added a colour line so you can see if it works. Add the extra protection you may require below

    Please Login or Register  to view this content.
    VBA Noob

  6. #6
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Quote Originally Posted by VBA Noob
    caliskier,

    The sheet is protect. Try this. I've added a colour line so you can see if it works. Add the extra protection you may require below

    Please Login or Register  to view this content.
    VBA Noob
    Still not working, no color change or locking.

  7. #7
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    By the way, CST is selected on another sheet, and linked to this sheet where it still says CST does that make a difference?

  8. #8
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Ok, I am seeing some results, got it to work when I type in CST on the sales sheet, need it to accept the link though. It is linked from Orders.

  9. #9
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    I am killing this topic and abandoning it. I did get it to work but for only one line, we have several lines to do it for. We will just manually lock as it will not change onece it is set. Thanks Noob for all your help. I am learning more and more, soon I will be able to help others.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,670
    Basic mistake
    The line
    Please Login or Register  to view this content.
    means if any cell changes to the value same as Range("F4"), it will execute.
    e.g If Range("F4") = Empty and you delete the contents of any other cell, it will execute.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Formulas won't work with change events (See link for more) then see attached. Change sheet2 cell A1 and then look at sheet 1

    http://www.cpearson.com/excel/Events.aspx

    jindon,

    I normally use

    Please Login or Register  to view this content.

    VBA Noob
    Attached Files Attached Files
    Last edited by VBA Noob; 01-06-2008 at 01:08 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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