+ Reply to Thread
Results 1 to 13 of 13

Lock tab after date shown in cell B1 which is different for each tab

  1. #1
    Registered User
    Join Date
    06-26-2025
    Location
    USA
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Lock tab after date shown in cell B1 which is different for each tab

    When the workbook is opened I need all the tabs which are past the month end date shown in cell B1 (different on each tab) to lock all the unprotected cells on said sheet. I need to be able to prevent changes to previous months reporting.

    The current password Mega123.

    I do not have alot of experience with VBA codes & such, so any help would be very appreciated!

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    8,046

    Re: Lock tab after date shown in cell B1 which is different for each tab

    Hi and welcome

    Paste the below into the ThisWorkbook module, then save the file, close and reopen.
    Please Login or Register  to view this content.
    See attached for the code in place.

    BSB
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    06-26-2025
    Location
    USA
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: Lock tab after date shown in cell B1 which is different for each tab

    Hmmm... this is not working for me. I am still able to change / input information even though the dates are passed.

    on the first tab, I double clicked on ThisWorkbook module & pasted the code above code, saved & reopened.

    Any suggestions?

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    8,046

    Re: Lock tab after date shown in cell B1 which is different for each tab

    I'd need to see your file with the code in place to work out why it's not working for you.

    Did you try the one I attached?

    BSB

  5. #5
    Registered User
    Join Date
    06-26-2025
    Location
    USA
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: Lock tab after date shown in cell B1 which is different for each tab

    I attached the file with the code you suggested.
    Attached Files Attached Files

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    8,046

    Re: Lock tab after date shown in cell B1 which is different for each tab

    When I open that, all the sheets that I'd expect to be protected are protected and I can make no changes, so looks like the code works fine to me.

    BSB

  7. #7
    Registered User
    Join Date
    06-26-2025
    Location
    USA
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: Lock tab after date shown in cell B1 which is different for each tab

    I also tried the one you attached, but If there are more months added, would need to be able to enter data into them.

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    8,046

    Re: Lock tab after date shown in cell B1 which is different for each tab

    The code checks if the date in B1 on each sheet is less than the current date, then it protects it. If it's not less than the current date then it leaves it unprotected. So adding more months would allow users to update them, until the date in B1 is in the past.

    BSB

  9. #9
    Registered User
    Join Date
    06-26-2025
    Location
    USA
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: Lock tab after date shown in cell B1 which is different for each tab

    Sorry If I am confusing...

    I attached another file with your code, but 2 add'l tabs which I need to remain editable until the month end date shown in B1.

    Thank you for your help!
    Attached Files Attached Files

  10. #10
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    8,046

    Re: Lock tab after date shown in cell B1 which is different for each tab

    And in that version I can edit the June and July sheets. As of Tuesday I will no longer be able to edit the June one, but still edit the July one.

    All seems to be working fine for me.

    If it's not for you then ensure you click "Enable Macros" if asked when opening.

    BSB

  11. #11
    Registered User
    Join Date
    06-26-2025
    Location
    USA
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: Lock tab after date shown in cell B1 which is different for each tab

    I can still edit the cells that I need protected in Jan, Feb, Mar tabs... Column AL cells 4,5,6,7,8 - Clolums E thru AF row 12,14,16,18, etc... basically all the uncolored cells on the entire sheet I need protected unless the date HAS NOT passed.

  12. #12
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    8,046

    Re: Lock tab after date shown in cell B1 which is different for each tab

    Ahh OK, I hadn't tested every cell

    I can see it's not doing what it's supposed to when I try to change those cells. Not 100% sure why though.

    Found this down the back of the internet... "Bug: There have been reports of bugs where even with locked cells, users can still edit them. This may require creating a support ticket with Microsoft to investigate further"

    Could be that if you built the thing from scratch and use that going forward it may resolve itself, but there's no guarantee.

    BSB

  13. #13
    Forum Contributor
    Join Date
    01-25-2025
    Location
    Presov, Slovakia
    MS-Off Ver
    2021
    Posts
    297

    Re: Lock tab after date shown in cell B1 which is different for each tab

    Hi DebFWDTM,
    you have next two more options to solve this:

    1. when locking the sheet, "uncheck" "Select locked cells"
    Lock tab.jpg

    2. copy another empty cell into the problematic cells.
    (Just to be sure, I'll describe what I mean by this:
    - unlock the sheet,
    - click on e.g. cell "AL1",
    - Ctrl C,
    - click on the problematic cell, or select several problematic cells,
    - Ctrl V, )

    m.s.
    Last edited by MSDols; 07-05-2025 at 10:17 AM. Reason: text correction

+ 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] Lock value in cells on/after a date in another cell
    By madmoo84 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2022, 04:27 PM
  2. Lock specific rows according actual date and lock always columns A and B
    By thorblow in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2022, 05:17 PM
  3. Lock a cell when a certain date in the month happens
    By evylmatt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2014, 01:13 AM
  4. Replies: 4
    Last Post: 05-01-2013, 07:38 PM
  5. [SOLVED] Move date shown in cell to new cell directly left once date has passed
    By jamieswift1977 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-16-2013, 11:23 AM
  6. Replies: 14
    Last Post: 09-11-2009, 08:50 AM
  7. Insert date then lock cell!
    By mevetts in forum Excel General
    Replies: 4
    Last Post: 12-21-2005, 06:23 AM

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