If/Then Formula Question

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

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top