0

Essentially I have a date field atop every column in may data that corresponds to the first of each month. There are several steps in this process that have already been completed but the last step is to lock every column that has a date value that is before the current date. The data is structured this way:

|43282   |43313   |43344   |43374    |43405    |43525   |
|7/1/2018|8/1/2018|9/1/2018|10/1/2018|11/1/2018|3/1/2019|
|$125    |$137    |$654    |$876     |$136     |$125    |

and so on. The code I am trying to use is as follows:

Sub LockDateCols()

Dim i As Range
For Each i In Sheets("Sheet1").Range("F1:AS1").Cells
    If i.Value < Int(CDbl(Now())) Then
        i.EntireColumn.Locked = True
    End If
Next i
End sub

Where F1:AS1 is the row of cells that contains the numeric date values. However when I execute this code it doesn't actually lock anything. What am I missing? In the example provided I want the rightmost column to be editable while locking the other 5 so just locking the whole sheet wouldn't work.

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
DBA108642
  • 1,995
  • 1
  • 18
  • 55

0 Answers0