Date and time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I need somebody to help me find the appropriate equation to do the
following:
When an employee selects his name from the drop down list in the cell
F1,today's date appears in A1 and time() in B2.
On the next day if an employee wants to change his name in the cell F1 and
selects another name,the date and time written in A1 and B2 DON'T change.
In other words,when users enter their names in F1 ,if A1 Is Null then
A1=today()
and if B1 Is Null then B1=NOW().
 
Hi

You could use a modification of the code that Bob Philips provided for
you


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F1"

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

If Range("A1") = "" Then
Range("A1") = Date
End If
If Range("B1") = "" Then
Range("B1") = Format(Now, "hh:mm")
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub
 
Back
Top