+ Reply to Thread
Results 1 to 8 of 8

Locking / Unlocking Cells

  1. #1
    Registered User
    Join Date
    01-21-2020
    Location
    Las Vegas, NV
    MS-Off Ver
    2016
    Posts
    14

    Locking / Unlocking Cells

    Hello, Hope someone can help.

    I have a sheet that needs to have cells locked or unlocked according to if then

    I have about 400 rows that can have data entered in, each row has 9 columns that can have data entered in, but I only want them to be able to enter in data on conditions.

    Starting with row 5
    IF B5 = 1 then
    Clear cells C5, E5,
    Lock Cells C5, E5
    Unlock Cells G5
    else if B5 = 3 Then
    Clear Cells G5
    Lock Cells G5
    Unlock Cells C5, E5
    Else If B5 = 4 Then
    Clear Cells E5, G5
    Lock Cells E5, G5
    Unlock Cells C5
    Else
    Clear Cells C5, E5, G5, H5, I5, J5, K5, L5
    Lock Cells C5, E5, G5, H5, I5, J5, K5, L5
    end if

    And I would need this for all 400 rows (row 5 through 405)

    Also Need to unlock or lock the next row based on column J having a value entered.

    IF J5 <> "" then
    Unlock B6
    end if


    Hope that all makes sense. Thanks for your help on this.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,538

    Re: Locking / Unlocking Cells

    It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    27,582

    Re: Locking / Unlocking Cells

    Hi,

    Maybe something like

    Please Login or Register  to view this content.
    Richard Buttrey

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    01-21-2020
    Location
    Las Vegas, NV
    MS-Off Ver
    2016
    Posts
    14

    Re: Locking / Unlocking Cells

    I will work on getting a sample worksheet created and get it uploaded.

  5. #5
    Registered User
    Join Date
    01-21-2020
    Location
    Las Vegas, NV
    MS-Off Ver
    2016
    Posts
    14

    Re: Locking / Unlocking Cells

    Ok got a sample file uploaded.

    So this is a file our sales team uses to enter in customers discounts they are requesting and then sent to off for approval.

    The goal is to lock down all the Cells until they enter in the correct info into the needed cells.

    Right now we have them highlight as green as they enter in data, but they still tend to just do what ever they want and some cells have code in them that get over written when they input the needed data. (K and M)

    First I need to move the code in F, H, K and M out and into VBA so they cant overwrite the code or delete it.

    Now onto the rules I need.

    To start all cells should be locked except for D6
    If they enter in 1 into D6 then clear E6, G6, I6, J6, K6, L6, M6 and lock the cells (Incase they had other data in there),
    then unlock I6,
    if I6 <> "" then unlock J6,
    then if J6 = L then K6 should = M, else if J6 = F and D6 = 1 then $ else if J6 = D then unlock K6
    then if K6 <> "" then unlock L6
    then if L6 <>"" then unlock M6 and D7 (So they can start the next entry)

    If they enter in 3 into D6 then clear E6, G6, I6, J6, K6, L6, M6 and lock cells (Incase they had other data in there),
    then unlock E6
    then if E6 <> "" then unlock G6
    then if G6 <> "" then unlock J6
    then if J6 = L then K6 should = M, else if if J6 = D then unlock K6 (J6 cant be F except for items, controlled by validation)
    then if K6 <> "" then unlock L6
    then if L6 <>"" then unlock M6 and D7 (So they can start the next entry)

    If they enter in 4 into D6 then clear E6, G6, I6, J6, K6, L6, M6 and lock cells (Incase they had other data in there),
    then unlock E6
    then if E6 <> "" then unlock J6
    then if J6 = L then K6 should = M, else if if J6 = D then unlock K6 (J6 cant be F except for items, controlled by validation)
    then if K6 <> "" then unlock L6
    then if L6 <>"" then unlock M6 and D7 (So they can start the next entry)

    This would need to be done so all 400 rows act like this.

    I have some data enter in on how it should flow to help guide someone.

    I know its alot to ask, but really need it as our sales team causes us alot of headaches when they don't enter in the info corectly and we need a way to lock it down so they are forced to enter in correct data.

    Pre Thanks to everyone who helps me out, this is way over my head when it comes to VBA stuff.

    Note: There might be some VBA code then now from things I was testing, just delete it if some was left in.
    Attached Files Attached Files
    Last edited by almulder; 01-21-2020 at 07:20 PM.

  6. #6
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    27,582

    Re: Locking / Unlocking Cells

    It seems that although this is essentially the same task the cells you now show are different to your original.

    It would have saved some time had you listed these latest cells in post #1

    However you can use the essence of the code I gave you, i.e. the three CASE statements and just extend the range references for this new set of rules. The code isn't difficult and it's readily understandable and easily changed. Just add it to your Module1 in the VBE. When you've done that amd if it still isn't working then reupload the workbook and I'll take a look.

  7. #7
    Registered User
    Join Date
    01-21-2020
    Location
    Las Vegas, NV
    MS-Off Ver
    2016
    Posts
    14

    Re: Locking / Unlocking Cells

    Ok thanks, I will will see what I can come up with this week. Thanks for your help.

  8. #8
    Registered User
    Join Date
    01-21-2020
    Location
    Las Vegas, NV
    MS-Off Ver
    2016
    Posts
    14

    Re: Locking / Unlocking Cells

    ok so the code does not work, keep throwing errors, but I figured out the issue and got it working, but now tweaking it and making it function for my needs.

    Thanks for your help
    Last edited by almulder; 01-23-2020 at 05:04 PM.

+ 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. Locking linked cells and then unlocking after moving
    By Jetstar77 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-10-2019, 07:19 PM
  2. Locking and unlocking of cells
    By srinivassurapareddi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 02:19 AM
  3. Locking/Unlocking Cells in Protected Worksheets
    By dteresinski in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2010, 08:26 AM
  4. Locking and Unlocking Cells
    By vikas.bhandari in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2010, 10:27 AM
  5. Formatting/locking/Unlocking range of cells
    By SSGMiami in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2009, 09:00 AM
  6. Locking and unlocking column cells using VB Macros
    By d.archana5 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-02-2009, 03:38 AM
  7. Unlocking/Locking Cells with a button
    By No.Solutions. in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2008, 11:27 AM

Tags for this Thread

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