+ Reply to Thread
Results 1 to 13 of 13

Locking Cell After Specified Date

  1. #1
    Registered User
    Join Date
    04-05-2012
    Location
    SA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Locking Cell After Specified Date

    Hi all.

    I've been trying all sorts of macros code from various searches but can't get any to work.


    See attached spreadsheet. Basically once the month of May has passed cell B7 should be locked. After the month of June cell C7 should be locked, and so on...

    The password for the sheet is "password"

    Can anyone help ASAP?

    Thanks.

    R.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Locking Cell After Specified Date

    Try this!

    I put

    Please Login or Register  to view this content.
    above the cells you want to lock. Then above that formula i put

    Please Login or Register  to view this content.
    so the macro compares the numbers...if the one on the bottom is smaller it locks the cell.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-05-2012
    Location
    SA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Locking Cell After Specified Date

    Thanks GF but what you have done only works if the worksheet is unprotected.

    The worksheet will always be locked with the password.

    Can you make it unprotect the worksheet, run the macros and then reprotect the worksheet?

    Also can the macros run when the worksheet/workbook is saved? (and not have to use a button)

    Thanks.

    R.

  4. #4
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Locking Cell After Specified Date

    go into the macro and add

    Please Login or Register  to view this content.
    at the very beginning

    Please Login or Register  to view this content.
    at the very end

  5. #5
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Locking Cell After Specified Date

    Here you go i made it run when saving, also did the protection thing for you
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-05-2012
    Location
    SA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Locking Cell After Specified Date

    Thanks again GF.

    I have moved a few things about (see attached) and get the following problem,

    When i enter the data on the "Profit Take-Up" tab in "Cell B7" then save and close it all works fine. But if i enter the data in the same cell then move to sheet 1 and try to save and close I get an error.

    One other thing aswell, now that i have made the cells unselectable if protected, will this effect the macros next month? or the months to come?

    Any ideas?

    Thanks.

    R.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-05-2012
    Location
    SA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Locking Cell After Specified Date

    Hi folks can anyone else help out with this?

  8. #8
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Locking Cell After Specified Date

    I'll work on this, basically the macro assumes you are on the profit tab already. I can fix it im having internet issues right now though.
    Last edited by GaidenFocus; 06-30-2012 at 03:44 PM.

  9. #9
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Locking Cell After Specified Date

    Here you go a simple sheets("Profit Take-Up").select was needed.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    04-05-2012
    Location
    SA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Locking Cell After Specified Date

    Thanks again GF really appreciate your time and help.

    It all works great until i copy the code and formulas from the test spreadsheet into the main spreadsheet. I get an error on line "ActiveCell.Offset(0, 1).Select"

    Cant figure out whats different! I've attached the main spreadsheet, can you have a look and let me know what you think?

    Thanks.

    R.
    Last edited by rwatson; 07-01-2012 at 09:48 AM.

  11. #11
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Locking Cell After Specified Date

    I have a cell with the word end in it at the end, you didn't copy it over. =)

  12. #12
    Registered User
    Join Date
    04-05-2012
    Location
    SA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Locking Cell After Specified Date

    Again thanks GF.

    Not sure if you noticed but the months of October, November and December lock too early. Think it may be because they have double digits for the month?

    Is there a work-around?

    Thanks.

    R.

  13. #13
    Registered User
    Join Date
    04-05-2012
    Location
    SA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Locking Cell After Specified Date

    Got it to work with a simple =TEXT((formula),"00")

    Thanks for all your help GF, it is very much appreciated.

    R.

+ 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