+ Reply to Thread
Results 1 to 37 of 37

HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

  1. #1
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Hi guys,

    Looking for help on 5 things:

    1. How do I get to show time as 09:00 AM or 13:00 PM without having to write colon? I just want to write straight 0900 and get it shown as 09:00 AM, same as the PM version.

    2. I know how to get duration/elapsed time by formula (example: 09:00 am (A3)- 1:30 pm (B3) is 4 hours 30 minutes "=TEXT(B3-A3,""hh:mm" is only showing elapsed time 04:30). But how do I get the elapsed time to automatically show as 4h30m in cell?

    3. How to show time as 13:30 pm? Tried using [h]:mm AM/PM but it's giving me error and doesn't work. hh:mm AM/PM shows 01:30 pm.

    4. Also, there is another time in other cell - lets say A5 5:40 pm. Why can't I use this formula (same as question 2 formula) "=TEXT(B3-A5),"hh:mm")?

    5. So as you can see, there is formula and when it's empty elapsed/duration time is showing 00:00. How do I get to hide this if there are no time/data?

    Need your advice. Thank you in advance.
    Last edited by Byambadorj; 05-10-2019 at 12:15 PM.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    does the attached answer some of your questions.
    torachan.
    Attached Files Attached Files

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Hi,

    Re 1.

    This Sheet change event code will convert an entry of say 1450 to 14:50 PM
    Please Login or Register  to view this content.
    Just make sure you code the relevant column/range - I've used A:A as an example.

    Re 2
    Once you have proper time numbers as a decimal of a day - which the above gives you then deducting one time from another will automatically give you the elapsed time in the format "hh:mm AM/PM" - just make sure you format the cell to that string.

    Re 3
    I don't believe you can show 13:30 PM. If you format a time number as "hh:mm AM/PM" then Excel reasonably enough assumes that since it's going to return either an AM or PM suffix, then it's reasonable and indeed correct to use a 12 hour clock.
    If you think it logically PM means 'post meridien' i.e. after midday, so a reference like 13:30 PM logocally says 13.5 hours AFTER mid-day.

    Re 4.
    I don't really understand that. Or to be more accurate I suspect that you've been using integer numbers like 930 and trying to manipulate them into a text string which displays the time, but of course it is merely a text string and can't be used in arithmetic.
    If you make sure all the time values you capture or decimals of a day then you'll avoid the problems you've encountered. When you enter say 9:30 with the colon you'll notice that of you format the cell as a number ot will display a decimal. That tells you Excel holds time as a decimal
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    What do you mean by adjust my own A:A? How would I make this code work? Plz help I'm a noob.
    Last edited by Byambadorj; 05-10-2019 at 10:10 PM.

  5. #5
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by torachan View Post
    does the attached answer some of your questions.
    torachan.
    Not quite what I was looking for. Hehe but it's nice touch. How do you do that data enter box?

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by Byambadorj View Post
    What do you mean by adjust my own A:A? How would I make this code work? Plz help I'm a noob.
    In the code there is a line

    Please Login or Register  to view this content.
    This is saying carry on with the macro if the cell you're changing is anywhere in column A. It's the Range("A:A") you need to change to refelect your situation

    But instead of us all guessing, why don't you upload the actual workbook so that we can be uite specific and add the code for you.

  7. #7
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by Richard Buttrey View Post
    In the code there is a line

    Please Login or Register  to view this content.
    This is saying carry on with the macro if the cell you're changing is anywhere in column A. It's the Range("A:A") you need to change to refelect your situation

    But instead of us all guessing, why don't you upload the actual workbook so that we can be uite specific and add the code for you.
    Sorry. I have attached the workbook. Can you please insert the macro/code you created onto the actual workbook? Thank u so much.
    Attached Files Attached Files

  8. #8
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    @Byam
    Please don't quote entire posts unnecessarily. They are just clutter and make threads hard to read.
    Use the "Quick reply" button instead.

  9. #9
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    then remove the quote option? why not use implemented feature?

  10. #10
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    It is sometimes necessary to use quotes when one is out of sequence, limiting the quotes to what is relevant to the new post, or when one needs to highlight a specific point in his answer.

    Is using the "Quick reply" a burden?

    Perhaps take a moment to remind yourself the forum guidelines ? https://www.excelforum.com/forum-rul...rum-rules.html
    Last edited by Pepe Le Mokko; 05-11-2019 at 09:30 AM.

  11. #11
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    How do I leave elapsed/duration time cell empty/blank if there are no time data?? Using this formulate to calculate elapsed time - =TEXT(E12-C12,"hh:mm"). Is there any formulate to add on this?

  12. #12
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    In F11 copied down (but excluding F13 (layover time):
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Alternatively, you could avoid making an exception of F13 using the following in F1 copied down. However, I don't know if this will survive modifications of your form for different itineraries.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by GeoffW283; 05-11-2019 at 05:37 PM.

  13. #13
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    In post #1 point 2 you are looking to have durations formatted like: 4h30m
    You could do this by simplifying the above formulas to remove the text() function and instead use a custom format for col-F as follows:
    h"h"mm"m"

    The above formulas would now become:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    or (to accommodate layover row):
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Also, is there a possibility that the departure - arrival times span midnight? If so then a further change to the above formulas would be necessary:
    Either:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    or (to accommodate layover row):
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by GeoffW283 View Post
    In post #1 point 2 you are looking to have durations formatted like: 4h30m
    You could do this by simplifying the above formulas to remove the text() function and instead use a custom format for col-F as follows:
    h"h"mm"m"

    The above formulas would now become:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    or (to accommodate layover row):
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Also, is there a possibility that the departure - arrival times span midnight? If so then a further change to the above formulas would be necessary:
    Either:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    or (to accommodate layover row):
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    #1 Time format worked amazingly. Thank u

    #2 This is also much simpler and easy. Works great.

    #3 Yes there will be a times where flights and arrivals will span midnight (i.e. departs at 21:30 PM on 2019/05/20 and arrive midnight 03:20 AM on 2019/05/21) how would I get this data correct? In this case, do I have to insert full date and time?

    Can you take a look at my actual workbook and add please?
    Attached Files Attached Files
    Last edited by Byambadorj; 05-12-2019 at 10:12 AM.

  15. #15
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    How can I enter times without having to write colon? Like an example I want to write straight 1345 and want it to be shown as 13:45 pm or 1:45 pm. But now, whenever I type in time 1345 it shows 0:00 (showing 9/6/1903 12:00:00 AM on formula bar)

    Is this possible to do? Thank you.

  16. #16
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by Byambadorj View Post
    Yes there will be a times where flights and arrivals will span midnight (i.e. departs at 21:30 PM on 2019/05/20 and arrive midnight 03:20 AM on 2019/05/21) how would I get this data correct? In this case, do I have to insert full date and time?
    Can you take a look at my actual workbook and add please?
    Thanks for the feedback on #1 & #2 - much appreciated.

    For #3: The last 2 formulas I provided in post #13 do accommodate flights that span midnight and durations should be calculated correctly using these formulas. That said, I'll take a look at your attached workbook and comment further if necessary.

  17. #17
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by Byambadorj View Post
    How can I enter times without having to write colon? Like an example I want to write straight 1345 and want it to be shown as 13:45 pm or 1:45 pm. But now, whenever I type in time 1345 it shows 0:00 (showing 9/6/1903 12:00:00 AM on formula bar)
    Is this possible to do? Thank you.
    Richard in post #3 had provided VBA code to do this. I'll look at your recent attached workbook and see if I can add. Note that this will mean that you will have to have a macro enabled workbook - are you and your company OK with that?

  18. #18
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Yes, its okay. Do I need to copy+paste that code by opening fresh VBA blank page and close excel -> save as macro-enabled workbook? Is that all or do I need to run it every time I open the workbook? Thank you, much appreciated.

  19. #19
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Did you bother to try my solution in #3?

    Here's your workbook which reflects your two columns C & E which contain dates
    Attached Files Attached Files

  20. #20
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    The attached itinerary_revA.xlsx is derived from your post #14 book3.xlsx with the following tweaks:
    • I added Richard Buttrey's post #3 macro and tweaked it to apply only to ranges C11:C15 and E11:E15. You should be able to see in the VBA how that has been done so that you can adjust those ranges if needed. I also tweaked the macro to ignore errors which could occur if, for example, you had to move the Layover row - the macro expects numbers!. In col-C and col-E you can now write times in 24 hour format as hhmm or hmm which I think is what you wanted.
    • In book3.xlsx you have entered full date and time for departure and arrival. That would remove the need to address midnight spans in the "duration" formula, but I thought you didn't want to do that, so I updated the col-F with the formulas I provided in my post #13 that automatically account for midnight spans. This approach is also compatible with the use of Richard's macro and your requirement to enter times like hhmm.
    • I moved the layover time back to the "duration" column or the col-E macro overwrites the formula!

    Thats all I did.

    All that said, dates and times and formatting and date/time arithmetic are confusing enough without adding macros into the mix. Hopefully as you update the worksheet for different itineraries we haven't caused maintainability problems here.

    Finally - note that you must have macros enabled for the above to work.

    Let us know if the attached itinerary_revA.xlsx does what you want or if you have further questions.
    Attached Files Attached Files

  21. #21
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Comparing Richard's post #19 file with my post #20 file:

    My file is based on Byambadorj's latest provided file, book3.xlsx from post #14, has the required formatting for the Duration column and deals correctly with departure/arrival times that span midnight.

    Richard's file is based on a prior Byambadorj post, book2.xlsx. It has a more elegant approach to defining the ranges to which the macro will be applied and it implements more robust error handling.

  22. #22
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by GeoffW283 View Post
    The attached itinerary_revA.xlsx is derived from your post #14 book3.xlsx with the following tweaks:
    • I added Richard Buttrey's post #3 macro and tweaked it to apply only to ranges C11:C15 and E11:E15. You should be able to see in the VBA how that has been done so that you can adjust those ranges if needed. I also tweaked the macro to ignore errors which could occur if, for example, you had to move the Layover row - the macro expects numbers!. In col-C and col-E you can now write times in 24 hour format as hhmm or hmm which I think is what you wanted.
    • In book3.xlsx you have entered full date and time for departure and arrival. That would remove the need to address midnight spans in the "duration" formula, but I thought you didn't want to do that, so I updated the col-F with the formulas I provided in my post #13 that automatically account for midnight spans. This approach is also compatible with the use of Richard's macro and your requirement to enter times like hhmm.
    • I moved the layover time back to the "duration" column or the col-E macro overwrites the formula!

    Thats all I did.

    All that said, dates and times and formatting and date/time arithmetic are confusing enough without adding macros into the mix. Hopefully as you update the worksheet for different itineraries we haven't caused maintainability problems here.

    Finally - note that you must have macros enabled for the above to work.

    Let us know if the attached itinerary_revA.xlsx does what you want or if you have further questions.
    This looks perfect. But a question rises again.

    Departure and Arrival can be either Ulaanbaatar to Seoul or Beijing. I had them lined in two rows because there can be times it will be one of them. And then I considered layover from Seoul or Beijing to Phuket. In that case, how would I calculate the layover time correctly?

    At the moment it doesn't seem to calculate the layover at Beijing (C15) to Phuket (E15). Also, why does the layover calculation formula include E13 which is blank and serves no purpose? Layover duration must be shown on F13.

    Thank you very much for what you are doing Geoff and Richard. Please take a look again?

  23. #23
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Please indicate how you use this when you have a layover. i.e what do you enter and where.

    Please upload an example where you have manually added what you expect to see and what the calculation is

    I was merely working on the original request to convert a 4 digit time to a hh:mm format automatically and this involved columns C & E.

    Incidentally I can't see any reference to E13 so somewhat confused.

  24. #24
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Current layover formula calculates layover between Seoul to Phuket. It's not calculating layover between Beijing to Phuket. Is it possible to add it to existing layover calculation or add another row and place it there?
    Attached Files Attached Files

  25. #25
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Richard - The reference to E13 is in itinerary_revA.xlsx cell F13 where I calculate the layover time. I was trying to have the same formula all the way down the "Duration" column. Now I'm not sure whether the benefit is worth the added complexity. I have merged your latest VBA updates into the attached file.

    Byambadorj - The layover time in the attached update is now calculated correctly for the route via Seoul and the roiute via Beijing. The F13 formula in fact is now much simpler - however, that is because it is specific to this particular itinerary. In F13:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Presumably you want to use this template for other routes? So just as Richard has requested in post #23 can you provide further info? For example, how would this template look for an itinerary, say with two layovers? Will you often have alternate routes on the same template? If so how many? What would the template look like if there were 3 route options, one direct, one with 1 layover, one with 2 layovers?
    Attached Files Attached Files

  26. #26
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Another thought: Would a layout like the following work for you?

    itinerary_proposal.png

    I have eliminated the unused alternate route from the itinerary and compensated for that by providing a dropdown list of destinations for ease of entry. "Layover" now gets its own column.

    This I think is a more flexible layout and leads to simpler and more logical formulas and hence easier maintainability.

  27. #27
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by GeoffW283 View Post
    Richard - The reference to E13 is in itinerary_revA.xlsx cell F13 where I calculate the layover time. I was trying to have the same formula all the way down the "Duration" column. Now I'm not sure whether the benefit is worth the added complexity. I have merged your latest VBA updates into the attached file.

    Byambadorj - The layover time in the attached update is now calculated correctly for the route via Seoul and the roiute via Beijing. The F13 formula in fact is now much simpler - however, that is because it is specific to this particular itinerary. In F13:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Presumably, you want to use this template for other routes? So just as Richard has requested in post #23 can you provide further info? For example, how would this template look for an itinerary, say with two layovers? Will you often have alternate routes on the same template? If so how many? What would the template look like if there were 3 route options, one direct, one with 1 layover, one with 2 layovers?
    The departure location will not change and it'll remain Ulaanbaatar but the route may change between Ulaanbaatar to Seoul and Phuket or Ulaanbaatar to Beijing and Phuket. That means it will only have 1 layover only.

    Regarding your latest post with drop down list. It looks really good and practical, also easy to follow. Could you attach it together with the formulas? Thank you.

  28. #28
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    As requested the attached file includes dropdown lists for departure and arrival airports.
    You can add or remove airports from the dropdown list simply by editing the "Destinations" worksheet. Time entry works exactly as before via Richard's macro.

    Duration in F11 copied down is:
    =IF(OR(C11="", E11=""), "", IF(E11-C11>=0,E11-C11,E11-C11+24))
    Layover in G11 copied down:
    =IF(C12="", "", C12-E11)
    Attached Files Attached Files

  29. #29
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by GeoffW283 View Post
    As requested the attached file includes dropdown lists for departure and arrival airports.
    You can add or remove airports from the dropdown list simply by editing the "Destinations" worksheet. Time entry works exactly as before via Richard's macro.

    Duration in F11 copied down is:
    =IF(OR(C11="", E11=""), "", IF(E11-C11>=0,E11-C11,E11-C11+24))
    Layover in G11 copied down:
    =IF(C12="", "", C12-E11)
    Thank you for this. Could you please simply explain how to use Richard's macro and apply it to my worksheet?

  30. #30
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Also how do you know when to use which formula like =IF(OR xxxxxx) and also how do you what things to write on Macro?? Where do you get or learn these? Please help me. I really, really wanna learn these.

  31. #31
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by GeoffW283 View Post
    As requested the attached file includes dropdown lists for departure and arrival airports.
    You can add or remove airports from the dropdown list simply by editing the "Destinations" worksheet. Time entry works exactly as before via Richard's macro.

    Duration in F11 copied down is:
    =IF(OR(C11="", E11=""), "", IF(E11-C11>=0,E11-C11,E11-C11+24))
    Layover in G11 copied down:
    =IF(C12="", "", C12-E11)
    I have copied and created my own spreadsheet like yours, used Richard's VBA macro. But it seems previously worked time formatting is not working. I cant enter times straight like 1350 and it wouldn't show as 13:50 PM or when I enter 0840 as 08:40 AM.

    What did I do wrong? Please help me. I have attached the file.
    Attached Files Attached Files

  32. #32
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    "Could you please simply explain how to use Richard's macro and apply it to my worksheet?"
    (1) See response (3) below.

    "Also how do you know when to use which formula like =IF(OR xxxxxx) and also how do you what things to write on Macro?? Where do you get or learn these?"
    (2) To learn the basics (or more, depending on your learning style) I would find a book or online tutorial that suits your style of learning. There's a whole host of recommended sources in this forum at: https://www.excelforum.com/excel-new...additions.html. Beyond that I personally learn best by working to solve specific problems: then, on this forum, when an expert/guru comes up with a better solution you learn again.

    "I have copied and created my own spreadsheet like yours, used Richard's VBA macro. But it seems previously worked time formatting is not working. I cant enter times straight like 1350"
    (3) You have placed the macro code in Module1. That is the wrong place for a macro that is responding to events, in this case a worksheet change event. The macro code needs to go on sheet1 instead.

    (4) I also noticed that you had not copied the F4 formula to F5 and have omitted the G4 and G5 layover formulas.

    I have attached your workbook with the above changes included.
    Attached Files Attached Files

  33. #33
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Thank you Geoff and Richards. Much appreciated.

  34. #34
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    No problem - glad you now have what you need. Thanks for the feedback.

    If your problem is resolved then can you please mark the thread as solved. To do this select Thread Tools from the menu link above your first post and mark this thread as SOLVED. Thanks!

  35. #35
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Thanks for the added reputation points - much appreciated!

  36. #36
    Forum Contributor
    Join Date
    05-14-2015
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Office 2021 Professional Plus
    Posts
    120

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    Quote Originally Posted by GeoffW283 View Post
    Thanks for the added reputation points - much appreciated!
    How can I remove that error message when entering time? I want to enter text or something else. How can I disable or edit that somewhere else?? Plz help

  37. #37
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: HELP - Duration/elapsed time with hours/minute stamp and leave blank if no data

    I just commented out the first 3 lines of the error handler at the bottom of the VBA code.
    That still allows you to enter time as 3 or 4 digits as required but alse lets you enter text without causing an error or clearing out the text.

    See attached workbook.
    Attached Files Attached Files

+ 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. Calculation of Time duration in hours from 24hours input data
    By maxonline in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-04-2016, 10:51 AM
  2. Replies: 2
    Last Post: 07-14-2015, 02:12 PM
  3. Calculate finish time given start time, working hours and job duration
    By swanseaexcel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-23-2012, 03:00 PM
  4. [SOLVED] Please Help - Trying to convert 1-2 sec data to a 5 minute Average based on time stamp -
    By elyk1173 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-31-2012, 10:34 AM
  5. Elapsed Time stamp ?
    By Nippy in forum Excel General
    Replies: 1
    Last Post: 04-17-2009, 04:19 PM
  6. [SOLVED] Elapsed Time over 24 hours
    By Fast Learner in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-17-2006, 08:55 PM
  7. Replies: 1
    Last Post: 04-08-2006, 10:45 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