Locking entire column once date passes

benntw

Board Regular
Joined
Feb 17, 2014
Messages
222
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet with dates in R3:CE3 . I was looking to have this auto lock the cells from edit anything two days prior to today's date. Columns A:Q are protected when I protect the sheet. R:CE are the only columns you can edit. Hopefully someone can help me out on this. Appreciate the help.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi benntw,

I do not believe there is any way to do this without using VBA. If simply changing the formatting (color/font/borders)of the cells is an option, it can be done with Conditional Formatting.




Doug
 
Upvote 0
I was looking to see if anyone had some VBA that would do the trick. I have seen some VBA that pertains to rows , but nothing for columns.
 
Upvote 0
Try this code in the Workbook Open event.

Code:
Private Sub Workbook_Open()

[FONT=Calibri][SIZE=3][COLOR=#000000]     Dim rng_DateRange As Range
    Dim cell As Range
    
    Sheet1.Unprotect
    
    Set rng_DateRange = Sheet1.Range("R3:CE3")
    
    For Each cell In rng_DateRange
    
        If cell.Value < Date - 2 Then
            cell.EntireColumn.Locked = True
        End If
    
    Next cell
    
    Sheet1.Protect
    
End Sub[/COLOR][/SIZE][/FONT]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,960
Messages
6,122,479
Members
449,088
Latest member
Melvetica

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top