+ Reply to Thread
Results 1 to 6 of 6

A macro for a Conditional Sheet Lock

  1. #1
    Registered User
    Join Date
    03-31-2021
    Location
    Kenya
    MS-Off Ver
    16
    Posts
    29

    A macro for a Conditional Sheet Lock

    Hi family,
    I am looking for a macro that, when the value in the in E8 is Pascal, then sheet1 remains active. But if the value in E8 is changed to something else like John, or when the value is deleted, then sheet1 on this workbook locks with (cannot be edited) with password 2222 until the value Pascal is re-entered again in E8. Is this really possible?
    Please help.
    See the uploaded file for more information.
    Attached Files Attached Files
    Last edited by Angulu; 03-24-2022 at 11:55 AM.

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

    Re: A macro for a Conditional Sheet Lock

    Start by unlocking cell E8. Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your Control sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter a value in E8 and press the RETURN key.
    Please Login or Register  to view this content.
    Please note that the sheet will be protected without a password. If you want to use a password, the macro will have to be modified.
    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
    Registered User
    Join Date
    03-31-2021
    Location
    Kenya
    MS-Off Ver
    16
    Posts
    29

    Re: A macro for a Conditional Sheet Lock

    Hi,
    This macro is locking the control sheet itself instead of sheet1 when values other than Pascal are placed in cell E8. Check, please.
    What if also we make the locking to be with a password as you said, how would the modified code look?
    Thank you this far.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: A macro for a Conditional Sheet Lock

    Change the password (in red) to suit your needs.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-31-2021
    Location
    Kenya
    MS-Off Ver
    16
    Posts
    29

    Re: A macro for a Conditional Sheet Lock

    Thanks, thanks, thanks 100 times!
    It works perfectly.
    have your star.

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

    Re: A macro for a Conditional Sheet Lock

    You are very welcome.

+ 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. [SOLVED] Run Macro When User Tries to Lock Sheet?
    By xtinct2 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-11-2021, 02:31 PM
  2. Macro to rename 1 worksheet only and lock the sheet
    By mattbarb101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-12-2019, 04:34 PM
  3. [SOLVED] Macro to unlock sheet, copy to new workbook, then re-lock original sheet
    By Foos Master in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-08-2015, 09:16 PM
  4. Macro to lock any cells where a conditional format is in effect
    By Savia in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-04-2014, 04:03 PM
  5. macro to lock sheet cells results @ COB
    By simpson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2011, 04:41 PM
  6. Replies: 10
    Last Post: 10-24-2009, 06:16 AM
  7. [SOLVED] need a macro to lock sheet
    By dgr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2006, 07:00 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