+ Reply to Thread
Results 1 to 2 of 2

Protect all columns except today’s date column

  1. #1
    Registered User
    Join Date
    11-26-2019
    Location
    Winnipeg, MB, Canada
    MS-Off Ver
    365
    Posts
    1

    Protect all columns except today’s date column

    Hello everyone,

    It's my first post here, thank you for your time,.

    I am building an excel sheet where users should not add any input into columns that do not match today's date, everyday.

    For example, if today is 26 November, then user cannot add their initials for the column of 25 november or 27 or any other day than today. Tomorrow this will be 27 and so on.

    I tried the following but something is not right:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim xRg As Range
    Set xRg = Target.Worksheet.Cells(5, Target.Column)
    If xRg <> Date Then
    ActiveSheet.Protect Password:="111111"
    MsgBox "Only today's date row can be edited!", vbInformation, "Kutools for Excel"
    ElseIf xRg.Value = Date Then
    ActiveSheet.Unprotect Password:="111111"
    ActiveSheet.EnableSelection = xlNoRestrictions
    End If
    End Sub

    I still can edit cells other than today's date.

    Any clue what I am doing wrong?

    Thank you!

    Youssef

  2. #2
    Forum Contributor
    Join Date
    02-04-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Office 2007 (home) Office 365 (work)
    Posts
    134

    Re: Protect all columns except today’s date column

    Hi

    Try the code below

    Please Login or Register  to view this content.

+ 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. Replies: 2
    Last Post: 02-28-2018, 10:01 AM
  2. [SOLVED] Please help!!! Countifs formula for the columns contains date today
    By kylechace in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2017, 05:05 AM
  3. [SOLVED] How to fill an array with values in column C based on Column D date value of Today
    By jrtraylor in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-10-2016, 07:44 PM
  4. [SOLVED] Unlock only if column date is equal to today's date +/- 2 days
    By Cobelatte in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-22-2015, 01:30 PM
  5. [SOLVED] Creating a view by filtering 2 columns by date (both within 3 months of today's date)
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-21-2014, 05:04 AM
  6. Auto hide columns when date is before today
    By Emrytate in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2013, 06:07 AM
  7. Password protect project & new directory with today's date
    By brianlois in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-01-2005, 06: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