Private Sub Worksheet_Change(ByVal Target As Range)
'Coded by SunnyKow - 19/09/2016
Dim tRow As Long
Dim tCol As Long
Dim sel As String
Application.EnableEvents = False
On Error GoTo ErrorRoutine
'You can change the range here
If Not Intersect(Target, Range("K:K")) Is Nothing Then
tRow = Target.Row
tCol = Target.Column
sel = Left(Target, 6)
Select Case True
Case sel = "Step 1"
If Cells(tRow, tCol + 1) = "" Then
Cells(tRow, tCol + 1) = Now
End If
Case sel = "Step 2"
If Cells(tRow, tCol + 2) = "" Then
Cells(tRow, tCol + 2) = Now
End If
Case sel = "Step 3"
If Cells(tRow, tCol + 3) = "" Then
Cells(tRow, tCol + 3) = Now
End If
Case sel = "Step 4"
If Cells(tRow, tCol + 4) = "" Then
Cells(tRow, tCol + 4) = Now
End If
End Select
'This update the validation list
Call Worksheet_SelectionChange(Target)
End If
Application.EnableEvents = True
Exit Sub
ErrorRoutine:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Coded by SunnyKow - 19/09/2016
If Not Intersect(Target, Range("K:K")) Is Nothing Then
Dim ValList As String
Dim c As Long
Application.EnableEvents = False
On Error GoTo ErrorRoutine
ValList = ""
For c = 1 To 5
If Target.Offset(, c) = "" Then
'You can change the validation list here
ValList = ValList & Choose(c, "Step 1: Arrived", "Step 2: Started", "Step 3: Finished", "Step 4: Shipped", "") & ","
Exit For
End If
Next
'Clear the validation cell
Selection.ClearContents
'You can change the validation settings here
With Selection.Validation
'Remove the old validation list
.Delete
'Add the new validation list
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=ValList
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
Application.EnableEvents = True
Exit Sub
ErrorRoutine:
Application.EnableEvents = True
End Sub