+ Reply to Thread
Results 1 to 3 of 3

Auto Lock Worksheet except if reference cell is blank

Hybrid View

  1. #1
    Registered User
    Join Date
    06-29-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2013
    Posts
    2

    Auto Lock Worksheet except if reference cell is blank

    I am working on a Log sheet where in the team will need to record all guest's requests. The worksheet will be automatically locked 3 days after todays date has passed. I already have a VBA however it auto locks the worksheet since the reference cell is blank. May I kindly ask for your assistance on how the macros will not work if the cell reference is blank. Please see below VBA used;

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Sheets("Request").Range("B3").Value < Date And Sheets("Request").Range("B3").Value < Date - 3 Then
            MsgBox "This workbook is LOCKED for editing."
        End If
    End Sub
    Thank you for your help

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Auto Lock Worksheet except if reference cell is blank

    Sub CHECK()
    
        If Sheets("Request").Range("B3").Value < Date And Sheets("Request").Range("B3").Value < Date - 3 And Sheets("Request").Range("B3").Value <> "" Then
            MsgBox "This workbook is LOCKED for editing."
        End If
    
    End Sub
    Last edited by mikeTRON; 06-30-2016 at 03:04 PM.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    06-29-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2013
    Posts
    2

    Re: Auto Lock Worksheet except if reference cell is blank

    Hi mikeTron,

    Thank you so much for your help. At first it didnt work with Sub check and I replaced it with Selection Change and it worked perfectly.

    Greatly appreciate your help

+ 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] VBA to auto-unlock a worksheet and then re-lock that sheet
    By Foos Master in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-08-2015, 09:14 PM
  2. Replies: 3
    Last Post: 01-23-2014, 12:19 PM
  3. Replies: 4
    Last Post: 05-03-2012, 06:23 PM
  4. Lock non-blank used cell using VBA
    By Anu shisha in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2010, 12:14 AM
  5. Lock Cell Reference
    By tpowell55 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2010, 08:05 AM
  6. lock cell reference in formulas
    By jayne1986 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-03-2009, 08:41 AM
  7. Can I lock worksheet reference?
    By Kathleen in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-04-2006, 03:20 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