+ Reply to Thread
Results 1 to 5 of 5

how to use Now() function in hh:mm format for vlookup??

  1. #1
    Registered User
    Join Date
    04-06-2012
    Location
    India
    MS-Off Ver
    Pro Plus 2019
    Posts
    86

    how to use Now() function in hh:mm format for vlookup??

    hi!

    I need help in using Now() function in hh:mm format for doing a vlookup.

    I am getting the current time using NOW() Function and my previous day's data is referenced with time in hh:mm format (not just in display format, but even created at backend in hh:mm format by actually typing in). But when I do a vlookup, I am not getting the data in the output since excel calculates the time in backend in decimal places, not just in hh:mm format for vlookup.

    For example, let us say the current time using Now() function is 09:15 (am) which is something like 41012.3854195602 (for 13 April 2012) for excel's own internal calculation. In another sheet I have entered data for 09:15 (am) which is equivalent to 0.385416666 for excel's calculation purpose.

    To match the decimals of Now() data for vlookup with with manual entry time, I took the Now() time and rounded it off to 4 decimal places so that it was matching the decimals of manual entry time. Therefore, 0.38541 of Now() is now equal to 0.38541 of Manual entry.
    So when I do a vlookup (and while my data is being updated in my excel sheet in real time for Now() function to work), I will get the vlookup result.
    However, sometimes when the rounded off values of Now() are not equal to Rounded off values of manual entry time, there is a mismatch and the data jumps to the last entry for 1-2 seconds, before again reverting back to actual current time.

    I was wondering if there is a more elegant solution to match the Now() time in hh:mm with my manually entered time in hh:mm. Please note that I am not talking about display in hh:mm format by changing the time format, but for actual time value in hh:mm format as read by excel.
    What I am unable to do is not being able to use is the FALSE condition with my vlookup during comparison of time. Since excel calulates time in decimals and not in human time format, I am currently forced to work with only for approximate matches which is giving me problems.

    Following 2 points may please be noted in this regard:
    1. Even though I am talking in terms of vlookup about, my data is in array format and I am fetching it using Index and Match functions, which are basically same as vlookup;
    2. I would prefer a formula running into multiple columns and rows rather than a Macro since macros generally do not allow reverting of calculations once done. But even than, visitors may advise me on Macros.

    Regards,

    Naira.

  2. #2
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: how to use Now() function in hh:mm format for vlookup??

    naira:

    it may be more helpful if you uploaded a sample file.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: how to use Now() function in hh:mm format for vlookup??

    when you use now() it includes seconds as well, so it is unlikely to find an exact match with an entry that just hrs and minutes. try something like =HOUR(NOW())&MINUTE(NOW()) for your match?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    04-06-2012
    Location
    India
    MS-Off Ver
    Pro Plus 2019
    Posts
    86

    Re: how to use Now() function in hh:mm format for vlookup??

    Thanks FDibbins
    Your solution works.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: how to use Now() function in hh:mm format for vlookup??

    glad to help, hope you gave me a star lol

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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