+ Reply to Thread
Results 1 to 2 of 2

Lock specific rows according actual date and lock always columns A and B

Hybrid View

thorblow Lock specific rows according... 06-12-2022, 11:17 AM
thorblow Re: Lock specific rows... 06-12-2022, 05:17 PM
  1. #1
    Registered User
    Join Date
    02-19-2018
    Location
    Czech Republic
    MS-Off Ver
    Excel 2016
    Posts
    68

    Lock specific rows according actual date and lock always columns A and B

    Hello!

    I have a sheet where columns A and B have only contain dates and then in T1 I have the actual date with formula =NOW()

    With the attached code, it locks all the cells if the date contained in cell B is older than the actual date. The code works good, but I would like to add another condition... In addition to what is doing the macro.. I would like to also lock always columns A and B under the same password shown below "123" no matter what is the actual date.

    Can somebody help me with this please?

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    If Range("B" & Selection.Row).value < Range("T1").value Then
    ActiveSheet.Protect Password:="123"
    MsgBox "Només es poden modificar les files del torn actual!!!", vbInformation, "Projecte Ebike"
    ElseIf Range("B" & Selection.Row).value > Range("T1").value Then
    ActiveSheet.Unprotect Password:="123"
    ActiveSheet.EnableSelection = xlNoRestrictions
    End If
    End Sub

  2. #2
    Registered User
    Join Date
    02-19-2018
    Location
    Czech Republic
    MS-Off Ver
    Excel 2016
    Posts
    68

    Re: Lock specific rows according actual date and lock always columns A and B

    Just an extra info:

    For me it would also work to have all the columns A and B locked together and also lock all the rows that have the dates shown in column B older than the actual date shown in cell T1

+ 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 whole sheet after a specific date
    By JyothiGrace in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2022, 01:49 AM
  2. Replies: 1
    Last Post: 01-24-2018, 01:52 AM
  3. Need to lock a sheet within a workbook after specific date
    By hewcarroll in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-28-2017, 01:17 PM
  4. lock specific cells in table but allow user to add rows
    By BrotherNeptune in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2015, 01:15 PM
  5. Lock formating on specific columns
    By Rob K in forum Excel General
    Replies: 1
    Last Post: 09-19-2014, 02:47 PM
  6. [SOLVED] Lock specific rows with a drop down box
    By ecraw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2014, 01:08 PM
  7. Replies: 4
    Last Post: 09-23-2013, 01:46 AM

Tags for this Thread

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