Hi, Bas. You mention in the spreadsheet that the user would like to use the + twice to change the date. The problem with that is that Excel recognizes that as a formula, which causes an error. However, this is possible using a single + or -. The one thing I don't really like about this is if you use ENTER after the + or -, it automatically moves the cursor to the next row, which then populates that date field as well (since the cell in the next row is selected). However, this can be changed in the options so that the cursor moves a different way (e.g. right).
Dim OldVal
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim Rng As Range
Set Rng = Range("A7:A11")
If Not Intersect(Target, Rng) Is Nothing Then
If IsDate(OldVal) Then
If Target = "+" Then
Target = OldVal + 1
ElseIf Target = "-" Then
Target = OldVal - 1
End If
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If IsEmpty(Cells(Target.Row, 1)) Then
If IsDate(Cells(Target.Row - 1, 1)) Then
Application.EnableEvents = False
Cells(Target.Row, 1) = Cells(Target.Row - 1, 1)
Application.EnableEvents = True
End If
End If
OldVal = Target
End Sub
HTH
Jason
Bookmarks