Public gPrevAchieved As Variant
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' ---- Quota message box section ----
Application.EnableEvents = False
If IsNumeric(Range("R6")) Then
If gPrevAchieved = "" Then
Application.EnableEvents = False
Application.Undo ' Get previous value
gPrevAchieved = Range("R6").Value
Application.Undo ' Restore current value
End If
If gPrevAchieved <> Range("R6") Then
If gPrevAchieved < 150 And Range("R6") > 149.99 Then
gPrevAchieved = Range("R6").Value
MsgBox "Congratulations!!!" & vbNewLine & vbNewLine & _
"You have made your quota for the day!" & vbNewLine & _
"Time to chillax..."
Else
gPrevAchieved = Range("R6").Value
End If
End If
End If
Application.EnableEvents = True
' ---- End of Quota message box section ----
' type in columns A-C to do a time stamp in column D. also capital HH:MM is for military time. hh:mm would be
' regular time so you could include am/pm. Example "hh:mm am/pm"
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("A:C"), .Cells) Is Nothing Then
Application.EnableEvents = False
With Range("D" & Target.Row)
If Not IsDate(.Value) Then
.NumberFormat = "HH:MM"
.Value = Now
End If
End With
Application.EnableEvents = True
End If
End With
' same as above but different range and target
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("F:O"), .Cells) Is Nothing Then
Application.EnableEvents = False
With Range("E" & Target.Row)
If Not IsDate(.Value) Then
.NumberFormat = "HH:MM"
.Value = Now
End If
End With
Application.EnableEvents = True
End If
End With
' takes first 3 characters from the drop down list in column C. drop down list was done by data validation
If Not Intersect(Target, Range("C8:C88")) Is Nothing And Target.CountLarge = 1 Then
Application.EnableEvents = False
Target = Left(Target, 3)
Application.EnableEvents = True
End If
End Sub