Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
Application.EnableEvents = False
Me.Unprotect
If Not Intersect(Target, [B:B,L:L]) Is Nothing Then
If Target.Value = "**" Then
Target.Value = Date
Target.NumberFormat = "DD/MM/YYYY"
End If
ElseIf Not Intersect(Target, [E1]) Is Nothing Then
If Target.Value = "" Then
Me.Range("A3:U3").AutoFilter Field:=Target.Column
Else
Me.Range("A3:U3").AutoFilter Field:=Target.Column, _
Operator:=xlFilterValues, _
Criteria1:="*" & CStr(Target.Value) & "*"
End If
ElseIf Not Intersect(Target, [A1:V1]) Is Nothing Then
If Target.Value = "" Then
Me.Range("A3:U3").AutoFilter Field:=Target.Column
Else
Me.Range("A3:U3").AutoFilter Field:=Target.Column, _
Operator:=xlFilterValues, _
Criteria1:=CStr(Target.Value)
End If
ElseIf Not Intersect([G:G], Target) Is Nothing Then
If Target = "**" Then
Dim rng As Range, cel As Range, highVal&, celVal&
Set rng = Range("G3:G" & Cells(Rows.Count, "G").End(3).Row)
highVal = 0
For Each cel In rng
celVal = Val(Replace(cel, "K-", ""))
If celVal > highVal Then highVal = celVal
Next
End If
Target = "K-" & highVal
End If
Me.Protect DrawingObjects:=False, Contents:=True, _
Scenarios:=False, AllowFormattingCells:=True, _
AllowFiltering:=True
Application.EnableEvents = True
End Sub