Can Excel automatically input times less than one second?

Paul B

Well-known Member
Joined
Feb 15, 2002
Messages
577
I know you can calculate times to 100th of a second by inputting them as hh:mm:ss.00. what I want to do is when I select a cell it will put the time in as h:mm:ss.00, the code below works for putting the time in, but I can’t get it to put the time in 100th of a second. If I put hh:mm:ss.00 as the format it returns the hours minutes and seconds but always gives me 00 for the 100th second part. Can this be done? I am using excel ’97 Thanks

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
'puts time in columns B and C when you select them
With ActiveCell
Select Case .Column
Case 2, 3
If Not (.HasFormula Or .Text <> "") Then
ActiveCell = Now()
ActiveCell.NumberFormat = "hh:mm:ss"
End If
End Select
End With
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Strange isn't it. This seems to work:

Code:
Sub Test()
    ActiveCell.Formula = "=NOW()"
    ActiveCell.Value = ActiveCell.Value
    Selection.NumberFormat = "hh:mm:ss.00"
End Sub
 
Upvote 0
Andrew, This is strange, if I run the sub once I get .00, if it is run again in the same cell it will display the 100th times, so I moved the Selection.NumberFormat = "hh:mm:ss.00" to the first line and it works! Thanks
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,168
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top