Results 1 to 2 of 2

Thread: Using VBA, how to display seconds decimals using format and now functions?

  1. #1

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



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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:
    Sub AltRight_Sub()
    On Error Resume Next
    Cancel = True
    Cells(Rows.Count, 2).End(xlUp).Offset(1) = Format(Now, "HH:MM:SS")
    End Sub

    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!

  2. #2
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    718
    Articles
    0
    Excel Version
    Excel 2010 64bit
    NeuroSpace

    Nobody need give their time towards a solution for your problem if it's already been solved.

    Please, if you're going to cross post, do it properly.

    Numerous forums refer to this http://www.excelguru.ca/content.php?184 for an understanding of why.



    http://www.mrexcel.com/forum/excel-q...ons-macro.html
    http://www.excelforum.com/excel-prog...functions.html
    http://www.excelguru.ca/forums/showt...-now-functions

    Any others?

Posting Permissions

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