CLick on Box to enter time of day

E

Elfego Baca

I have a worksheet where payment is entered in column C. I would like to
use Column B as a time stamp. In other words as soon as data is entered
in C5 then the exact time comes up in B5. When data is entered in C6
then the exact time cones up in C5. I do not want this time to change
even when the page is saved and opened later on.
 
G

Gord Dibben

Elfego

You can enter a static time in a cell by hitting CTRL + SHIFT + ;(semi-colon)

You could also use event code to enter a static date when you enter something in
a cell.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col C
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 3 Then
n = Target.Row
If Excel.Range("C" & n).Value <> "" Then
Excel.Range("B" & n).Value = Format(Now, "hh:mm:ss")
End If
End If
enditall:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste the above into that module.

Enter a value in C1 and B1 will return a static date.


Gord Dibben MS Excel MVP
 
Top