+ Reply to Thread
Results 1 to 4 of 4

Time Formula, Any ideas why I'm getting an error?

  1. #1
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Time Formula, Any ideas why I'm getting an error?

    I have a table with time range data in the following format: 1100P-0259A. I've written a formula that finds the midpoint of that time range, so in this example, it would be 1:00 AM.

    Please Login or Register  to view this content.
    The formula appears to display the correct time within the cell, but when you change the format to "number" you see that it has 1 added to it. So, 1:00 AM should be .04166667, but it is 1.04166667. I'm guessing this is because the time range crosses midnight. Is there a quick fix for this, or do I have to add an IF condition?

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,800

    Re: Time Formula, Any ideas why I'm getting an error?

    You can add this to the beginning, instead of the = :

    =MOD(

    and add this to the end:

    ,1)

    so that you now have:

    =MOD( your_formula ,1)

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Time Formula, Any ideas why I'm getting an error?

    Thanks Pete!

    Quick question: That worked for the vast majority of my data, except for when the resulting time was midnight. The number value is 1.00 instead 0.00. Any thoughts?

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,800

    Re: Time Formula, Any ideas why I'm getting an error?

    Well, it might be a very small fraction of a second before midnight, but with the rounding that you have you won't be able to see the difference. To see if it is exactly 1, put this formula in a blank cell somewhere:

    =cell_with_formula = 1

    You will get TRUE if it is. Change the second = to < or > to investigate further - I would suspect you will get TRUE for < and FALSE for > and =.

    Hope this helps.

    Pete

+ 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. Trying to change text in an autoshape but i get an error. Any ideas
    By Jats in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-01-2013, 10:56 AM
  2. VLOOKUP, #NA error, pic included, any ideas on how to fix this?
    By Geoffo123 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 11-21-2012, 07:04 PM
  3. [SOLVED] Need ideas to return time…
    By [email protected] in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-19-2012, 09:00 AM
  4. [SOLVED] [SOLVED] Object required error - Still perservering with this code - Ideas
    By justagrunt in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-17-2006, 06:35 PM
  5. [SOLVED] Time question-Can this be done, if so any ideas?
    By Anthony in forum Excel General
    Replies: 1
    Last Post: 10-09-2005, 01:05 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