ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If/Then Formula Question (https://www.excelbanter.com/excel-discussion-misc-queries/59968-if-then-formula-question.html)

k3639

If/Then Formula Question
 
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.

Chip Pearson

If/Then Formula Question
 
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


"k3639" wrote in message
...
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.




k3639

If/Then Formula Question
 
Thanks for your assistance, that works perfectly!

"Chip Pearson" wrote:

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


"k3639" wrote in message
...
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.






All times are GMT +1. The time now is 12:40 PM.

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