Step 1: Unlock cells.
- Select all cells that the user should be able to change, in particular the start date range.
- Press Ctrl+1 to activate the 'Format Cells' dialog.
- Activate the Protection tab.
- Clear the Locked check box.
- Click OK.
Step 2: Conditional formatting.
- Select the due date range. In the following, I'll assume that it is B2:B1000, and that B2 is the active cell within the selection.
- On the Home tab of the ribbon, select Conditional Formatting > New Rule...
- Select 'Format only cells that contain'.
- Leave the first dropdown set to 'Cell Value'.
- Select 'less than' from the second dropdown.
- Enter =TODAY() in the box next to it.
- Click Format...
- Specify red as font color.
- Click OK, then click OK again.
Step 3: Protect the sheet.
- Right-click the sheet tab.
- Select 'Protect Sheet...' from the context menu.
- Use the check boxes to specify what the user will be allowed to do.
- At the very least, leave 'Select unlocked cells' ticked (And 'Protect worksheet...' of course).
- If you want to specify a password that will be needed to unprotect the sheet, enter it in the Password box. Don't forget the password!
- Click OK. If you specified a password, you'll have to enter it again as confirmation.
Step 4: VBA code.
- Right-click the sheet tab.
- Select 'View Code' from the context menu.
- Copy the following code into the worksheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Not Intersect(Range("A2:A1000"), Target) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Me.Unprotect Password:="secret"
For Each rng In Intersect(Range("A2:A1000"), Target)
If IsDate(rng.Value) Then
rng.Offset(0, 1).Value = rng.Value + 14
Else
rng.Offset(0, 1).ClearContents
End If
Next rng
Me.Protect Password:="secret"
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
- Change the range A2:A1000 to the range of start dates.
- Change "secret" to the password that you used. If you didn't use a password, use "".
- Switch back to Excel.
- Final steps.
- Save the workbook as a macro-enabled workbook (.xlsm).
- Users should allow macros when they open the workbook.