+ Reply to Thread
Results 1 to 10 of 10

Thread: Lock the sheet once date is passed

  1. #1
    Registered User
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    93

    Lock the sheet once date is passed

    Hi,

    I need to lock the sheet automatically once the date is passed. I have attached the sample sheet.

    Please give your input and guide me about this.
    Last edited by anwitha; 12-11-2011 at 12:57 AM.

  2. #2
    Valued Forum Contributor Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens Greece
    MS-Off Ver
    Excel 2003
    Posts
    2,299

    Re: Lock the sheet once date is passed

    Hi anwitha

    You can do this, using Validation(Data>Validation>Custom)

    You can not use NOW() function,in B2,
    because in this case, the result(a2-b2), changes every second!!

    The formula that you have to use in Validation(marking all the Sheet) is:

    =SUM($A$2-$B$2)<2)

    Hope to helps you.

    Regards
    Regards

    Fotis.

    I am proud that i am Greek.

    Just to know every one.We Greeks, we are nοt proud of our politicians. Υou?

    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.


    My Avadar picture, is from Athens Acropolis.
    http://www.theacropolismuseum.gr

    http://www.visitgreece.gr/

  3. #3
    Registered User
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Lock the sheet once date is passed

    Hi Fotis

    Thanks for your reply but I want when that date is crossed after 2 days entire sheet should get locked...any idea how to do that?

    Regards,
    Anwitha

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    825

    Re: Lock the sheet once date is passed

    hi Anwitha,
    as an option try this one and see if it helps you
    Private Sub Workbook_Open()
    If [b2] - [a2] >= 2 Then Sheets(1).Protect "123"
    End Sub
    Regards, John

  5. #5
    Registered User
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Lock the sheet once date is passed

    Hi Joh,

    Thanks for your help. but I have given specified cell access to all the users I want that given specified cell should lock once the date is passed 2 days. The code which you have provided is not working in this scenario. Is there any other option availabe to do that?

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    825

    Re: Lock the sheet once date is passed

    hi,
    add the code in the workbook_open event, if the date in cell a2 is < or = with 2 days than the date in cell b2 when you open the file the sheet is protected.
    the password is 123. go to main meniu, Review, Unprotect Sheet, password 123.
    see the file attached.
    hope it helps you
    Attached Files Attached Files
    Last edited by john55; 12-10-2011 at 02:31 AM.
    Regards, John

  7. #7
    Registered User
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Lock the sheet once date is passed

    Hi John,

    Please refer to the newly attached sheet. I have given the access to the users to update only for the column F apart from that they are not able to edit any other cells. My concern is if the date in A2 cell is more than 2 days to B2 Cell then that F column also should get locked.

    Attached the sample sheet for your reference.

    Thanks.
    Sambashiva
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    825

    Re: Lock the sheet once date is passed

    I am sorry, perhaps someone else has another approach.
    Last edited by john55; 12-10-2011 at 03:56 AM.
    Regards, John

  9. #9
    Valued Forum Contributor
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    Excel 2010
    Posts
    522

    Re: Lock the sheet once date is passed

    maybe so
    Sub Button2_Click()
    With Sheets(1)
        .Unprotect "123"
        .Columns("F:F").Locked = .[b2] - .[a2] > 2
        .Protect "123"
    End With
    End Sub
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Lock the sheet once date is passed

    Hi nilem.

    Its working fine Thanks for your help.

+ 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.2.0