If/Then Formula Question

K

k3639

I am attempting to create a timesheet, where if a particular cell is clicked
on, the current time/date stamp will generate via the Now() function. I am
having trouble with how to indicate that the timestamp should be entered if
the cell is clicked on. Also, can the timestamp be displayed in the same
cell, take cell A1 for example. Any assistance is appreciated. I have both
2000 and 2003 available.
 
C

Chip Pearson

Put the following code in the worksheet's code module
(right-click the tab and choose View Code).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

With Target
If .Address = "$A$1" Then
.Value = Now
.NumberFormat = "hh:mm:ss"
End If
End With

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Top