+ Reply to Thread
Results 1 to 6 of 6

Using VBA, how to display decimal seconds using format and now functions?

  1. #1
    Registered User
    Join Date
    02-01-2014
    Location
    Planet Earth
    MS-Off Ver
    Excel 2011
    Posts
    3

    Using VBA, how to display decimal seconds using format and now functions?

    Hello everyone!

    I am using the following VBA macro, which inputs timestamps every time a key combination (alt+right arrow in this case) is pressed:
    Please Login or Register  to view this content.
    I would like this to display decimal seconds as well. Is there a quick change I can make to the formatting of "HH:MM:SS" which will work?

    So far I've tried "HH:MM:SS.0" and similar variations, which only appends to the seconds whatever follows the period; and "HH:MM:SS:MS" and similar variations, but that only redisplays the minute and second values.

    I am using Excel 2011 on Mac OS 10.9.1

    Thanks!

    EDIT: Added code tags
    Last edited by NeuroSpace; 02-01-2014 at 12:52 PM.

  2. #2
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Using VBA, how to display decimal seconds using format and now functions?

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Using VBA, how to display decimal seconds using format and now functions?

    Please edit your post and include code tags around the code - this is one of the forum rules you agreed to when you joined. To add Code tags, edit the message, highlight the code and click the '#' button on the toolbar.

    After doing that, you can try this as an alternative...
    Please Login or Register  to view this content.
    You should note that the VBA NOW() function seems to return whole seconds only. The easiest way to get the exact time is to use the WorkSheet Now() function, or the Windows API. The worksheet function is simpler...

    You can remove the [] around Now() and compare the results to see the differences.

    That reminds me...
    Please Login or Register  to view this content.
    is an alternative.
    Last edited by cytop; 02-01-2014 at 09:53 AM.

  4. #4
    Registered User
    Join Date
    02-01-2014
    Location
    Planet Earth
    MS-Off Ver
    Excel 2011
    Posts
    3

    Re: Using VBA, how to display decimal seconds using format and now functions?

    Quote Originally Posted by G e r a r d View Post
    Please Login or Register  to view this content.
    Gerard thank you for replying! This code doesn't work for me, it simply returns .00 after the seconds.

    Cytop, thank you very much for your help, I feel like I'm almost there with your suggestion. My code right now looks like this:
    Please Login or Register  to view this content.
    This returns values which are formatted like so 17:13.49.84, which doesn't allow me to do any calculation on it.

    Is there a way of getting the second decimal information and still use the numbers for calculations? What I need is to measure time intervals between two events in a series.

    EDIT: EDIT: So for the solution of my problem I would just need to modify this:
    Please Login or Register  to view this content.
    , which gives the seconds and decimals to something that only gives decimals. Then I could make a time stamp in the following format: HH:MM:SS,ds which allows calculations.

    Cytop, can you please help me? Thanks!
    Last edited by NeuroSpace; 02-01-2014 at 12:49 PM.

  5. #5
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Using VBA, how to display decimal seconds using format and now functions?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-01-2014
    Location
    Planet Earth
    MS-Off Ver
    Excel 2011
    Posts
    3

    Re: Using VBA, how to display decimal seconds using format and now functions?

    Gerard, this does exactly what I need! Thanks a lot!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Format display decimal values but no decimal point
    By BecParko in forum Excel General
    Replies: 1
    Last Post: 10-18-2007, 04:42 AM
  2. how do I format a cell to display in degrees minutes seconds
    By r_edwards in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-09-2006, 12:15 PM
  3. Replies: 1
    Last Post: 12-17-2005, 08:55 PM
  4. [SOLVED] display no seconds in time format [h]
    By Finolac in forum Excel General
    Replies: 1
    Last Post: 10-03-2005, 11:05 AM
  5. [SOLVED] Format a cell to display decimal hours.
    By Fred Holmes in forum Excel General
    Replies: 2
    Last Post: 03-18-2005, 12:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1