Keeping a date from changing

S

Steve Cohen

If have some code on my page that enters todays date in Colum D when a
choice from the drop down menu in Colum F is made.

I'm looking to change it a bit so that if I change the entry in Colum f and
a date is already in colum D it will keep what is there instead of changing
it to today's day

The existing code is...

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub

On Error GoTo errHandler:

Application.EnableEvents = False
If LCase(Target.Value) = "bet" Then
With Target.Offset(0, -2)
..Value = Date
..NumberFormat = "MM/DD/YY"
End With
ElseIf LCase(Target.Value) = "cash back" Then
With Target.Offset(0, -2)
..Value = Date
..NumberFormat = "MM/DD/YY"
End With
Else
Target.Offset(0, -2).ClearContents
End If

errHandler:
Application.EnableEvents = True

End Sub
_________________
Thanks

Steve
 
O

Otto Moehrbach

Steve
Put this line immediately before your "If LCase...." statement:
If IsDate(Target.Offset(, -2) Then Exit Sub
HTH Otto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top