Hi Rajesh,
Please don't post question on Tips & Tricks forum. That forum meant to be provide cool tips and tricks only.
If you have a specific question please post the question on the main forum.
Paste the following code in ThisWorkbook module of your workbook.
adjust the sheet name and the range.Code:Private Sub Workbook_Open() Dim wksTarget As Worksheet Dim rngDate As Range Dim rngData As Range Dim c As Long Dim LastRow As Long Dim LastCol As Long Const RangeToLock As String = "C:AG" '<< adjust to suit Const Pwd As String = "pwd" Set wksTarget = ThisWorkbook.Worksheets("Sheet1") '<< adjust to suit If Not blnUnlockedAllCells Then wksTarget.Cells.Locked = False blnUnlockedAllCells = True wksTarget.Protect Password:=Pwd, userinterfaceonly:=True End If With wksTarget LastRow = .Range("a" & .Rows.Count).End(xlUp).Row LastCol = .Cells(2, .Columns.Count).End(xlToLeft).Column Set rngData = wksTarget.Range("a2", .Cells(LastRow, LastCol)) End With For c = 3 To rngData.Columns.Count If CDate(rngData(1, c)) <= Date - 2 Then On Error Resume Next rngData.Columns(c).SpecialCells(2).Locked = True On Error GoTo 0 End If Next End Sub





Reply With Quote
Bookmarks