Date Time Stamp Formula

K

katie.teitelbaum

Hello,
I am trying to create a formula that will insert the date and time into
a new cell only when another cell is "0". In other words, if the
specific cell hits 0, then the current date and time when the cell hits
0 is recorded in the other cell. If the cell is anything except 0,
then the other cell is blank or says "not finished". I tried the if
and now formulas to no avail and my macro is returning a VALUE error,
so I'm completely lost. Any help would be much appreciated.

Thanks,
Katie
 
B

Bob Phillips

Katie,

It is a lot simpler with VBA This tests A1 and puts the date and time in B1

Option Explicit

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

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.Offset(0, 1).Value = Format(Now, "dd mmm yyyy hh:mm:ss")
Else
.Offset(0, 1).Value = ""
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Top