Jun 28 2021 03:31 PM
Jun 29 2021 02:48 AM
It's a bit difficult to visualize what you want. Could you attach a small sample workbook to illustrate your problem?
Jun 29 2021 07:40 AM
Jun 29 2021 07:58 AM
SolutionStep 1:
Select all cells that the user should be able to edit in principle.
Press Ctrl+1 to activate the Format Cells dialog.
Activate the Protection tab.
Clear the Locked check box.
Click OK.
Step 2:
Press Alt+F11 to activate the Visual Basic Editor.
In the Project Explorer pane on the left, double-click ThisWorkbook under Microsoft Excel Objects.
Copy the following code into the module:
Private Sub Workbook_Open()
Dim c As Long
Dim m As Long
With Worksheets(1) ' or Worksheets("NameOfSheet")
.Protect Password:="Secret", UserInterFaceOnly:=True
m = .Cells(1, .Columns.Count).End(xlToLeft).Column
For c = 2 To m
If .Cells(1, c).Value >= Date Then Exit For
.Cells(1, c).EntireColumn.Locked = True
Next c
End With
End Sub
Step 3:
Switch back to Excel.
Save the workbook as a macro-enabled workbook (.xlsm).
Make sure that you allow macros when you open it.
Jun 29 2021 07:58 AM
SolutionStep 1:
Select all cells that the user should be able to edit in principle.
Press Ctrl+1 to activate the Format Cells dialog.
Activate the Protection tab.
Clear the Locked check box.
Click OK.
Step 2:
Press Alt+F11 to activate the Visual Basic Editor.
In the Project Explorer pane on the left, double-click ThisWorkbook under Microsoft Excel Objects.
Copy the following code into the module:
Private Sub Workbook_Open()
Dim c As Long
Dim m As Long
With Worksheets(1) ' or Worksheets("NameOfSheet")
.Protect Password:="Secret", UserInterFaceOnly:=True
m = .Cells(1, .Columns.Count).End(xlToLeft).Column
For c = 2 To m
If .Cells(1, c).Value >= Date Then Exit For
.Cells(1, c).EntireColumn.Locked = True
Next c
End With
End Sub
Step 3:
Switch back to Excel.
Save the workbook as a macro-enabled workbook (.xlsm).
Make sure that you allow macros when you open it.