Infinite opportunities?  Endless problems?  Limited resources?  Talk to us!
Operations
Consulting
Software
Consulting
Publishing and
Training
Applied
Solutions
Excel add-ins
and tutorials
Charts Excel and VBA
Case Studies
VBA
tutorials
PowerPoint
Add-Ins
Miscellenia
You are on the Home/Excel/Excel Tips/Enter time with seconds page
About this site

What's new

Google
Web
This Site
 

 

Enter time in seconds

Do you want to enter the current time in a cell so that it doesn't change each time Excel recalculates formulas?  Then, use CTRL+SHIFT+:  However, Excel only provides the time in hours and minutes or HH:MM.  To enter the time so that it includes seconds, one has to override the default behavior.

Enter the code below in a standard module:

Option Explicit
Sub setKey()
    Application.OnKey "+^:", "EnterTime"
    End Sub
Sub resetKey()
    Application.OnKey "+^:"
    End Sub
Sub EnterTime()
    With ActiveCell
    .Value = Time()
    .NumberFormat = "hh:mm:ss"
        End With
    End Sub

Now, once you run the setKey procedure, the CTRL+SHIFT+: will give you the time in seconds. To return Excel to its default behavior, run the resetKey procedure.
 

By accessing any page or link on this web site other than this page, you agree to the terms and conditions.

 

For custom technology solutions, operations consulting, or training contact web-underscore-contact@tushar-hyphen-mehta-dot-cee-oh-em.
By accessing any page or link on this web site other than this page, you agree to the terms and conditions.

Ads from amazon.com

[Optional] Survey (current rating of site: 3.7 out of 4)  If you will take a moment to provide your comments, it will help improve the site both for you, and for other visitors.

On a scale of 4 (just what I need)
to zero (totally useless)

How do you rate the information

on this page?

  on this site?

[Optional]

Your name
Your email address
Other comments
 
Monitor page
for changes
    
   it's private  

by ChangeDetection
A comment selected at random:

 

 

Copyright © 2000-2008 Tushar Mehta.
Send comments and suggestions about the web site to webmaster@tushar-hyphen-mehta-dot-cee-oh-em
Last edited April 14, 2008