ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Date and time (https://www.excelbanter.com/excel-discussion-misc-queries/134416-date-time.html)

Pietro

Date and time
 
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().

Roger Govier

Date and time
 
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



--
Regards

Roger Govier


"Pietro" wrote in message
...
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().





All times are GMT +1. The time now is 09:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com