Results 1 to 14 of 14

Thread: Excel VB question...Please assist [RESOLVED]

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2004
    Location
    Everywhere
    Posts
    46

    Resolved Excel VB question...Please assist [RESOLVED]

    I will try to explain this as well as I possibly can. I know most of you will not download files on here in fear of a virus and I understand. So, I will try to explain and illustrate as much as I can.

    I have an Excel spreadsheet of...let's say truck drivers. We'll say they deliver for your local FedEx. Each time they pick up a load of packages at the terminal, they have several stops to drop all of those packages off. On the spreadsheet, I have driver name, load number, stop number, arrival date, arrival time, depart date, depart time, total time, total time in mins, & stop mins.

    Now, let me explain what each one is...

    Driver Name - Obviously the drivers name, or driver number, if you will

    Load Number - This is the number assigned by the terminal for that load or haul

    Stop Number - The number of stops, or deliveries per load. In other words, each time the FedEx guy drops a package at a house, the stop number increases by one. This is already defined and can vary from 3 stops to 10 stops.

    Arrival Date - Date the package was delivered. Already populated.

    Arrival Time - Time the package was delivered. Already populated.

    Depart Date - Date the driver left that stop. Already populated.

    Depart Time - Time the driver left that stop.

    Total Time - The total time it took for that LOAD to be completed. Not that particular stop, but the ENTIRE LOAD. This needs to be calculated.

    Total Time In Mins - Same as above except in minutes. This needs to be calculated.

    Stop Mins - This is the total difference between arrival time and depart time, taking the date into account. This is also considered "down time." This needs to be calculated.

    *all times are in standard military time8

    Example Set

    **not going to work...I'll post a txt file**
    Last edited by Myriad_Rocker; Dec 2nd, 2004 at 11:37 AM.
    Myriad Rocker
    The ability to speak does not make you intelligent

    I haven't had VB since college...go easy.

  2. #2

    Thread Starter
    Member
    Join Date
    Nov 2004
    Location
    Everywhere
    Posts
    46
    Here's the text file. Let me know if there are any problems with it.
    Attached Files Attached Files
    Myriad Rocker
    The ability to speak does not make you intelligent

    I haven't had VB since college...go easy.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    You can do it in either an Excel formula or using VB and code calculations.
    Would be easier maybe to use Excel, maybe.

    I assume that the spreadsheet has multiple groupings and date
    ranges?

    Your looking for the Formula to do the calcs, right?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2004
    Location
    Everywhere
    Posts
    46
    It can be done with formulas? How so? How would the formula know how far to take the calc?
    Myriad Rocker
    The ability to speak does not make you intelligent

    I haven't had VB since college...go easy.

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2004
    Location
    Everywhere
    Posts
    46

    Unhappy

    Anyone?
    Myriad Rocker
    The ability to speak does not make you intelligent

    I haven't had VB since college...go easy.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I'm home now. I loaded the textfile into Excel and I think it just
    needs formatting. Give me some time.

    Be back.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2004
    Location
    Everywhere
    Posts
    46
    Keep in mind, that's just example data.
    Myriad Rocker
    The ability to speak does not make you intelligent

    I haven't had VB since college...go easy.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Update:
    I tried a few different formatting ideas but to no avail.

    So, with that said I wanted to know if the solution would be
    acceptable in VBA or do you need it in VB?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Member
    Join Date
    Nov 2004
    Location
    Everywhere
    Posts
    46
    Thanks for your support!

    Question, though...at the cost of sounding like a moron, I'm going to ask you what the difference is between VB and VBA.
    Myriad Rocker
    The ability to speak does not make you intelligent

    I haven't had VB since college...go easy.

  10. #10
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961
    Originally posted by Myriad_Rocker
    Thanks for your support!

    Question, though...at the cost of sounding like a moron, I'm going to ask you what the difference is between VB and VBA.
    VB is going to be a stand-alone Visual Basic application, like an EXE, developed in Visual Studio.

    VBA is Visual Basic-like code inserted into an Office document like Word, or Excel or Outlook.

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Thats a legitimate question.

    VBA: the VB like development enviroment behind MS Office
    applications like Excel, Outlook, Word, etc. It can not compile the
    project into exe's. The VBA Project is tied to the front end of Excel
    for example. You can reference other Excel VBA projects if they
    are not protected or password protected.

    VB: the more powerful development enviroment that can create
    stand alone applications. It can compile projects into exe's, dll's,
    ocx's,etc.

    VBA has some of the same functions, methods, and syntax of vb,
    thats why people get the two confused.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    Member
    Join Date
    Nov 2004
    Location
    Everywhere
    Posts
    46
    Okay, that's what I thought.

    VBA is fine. Thanks for all your help!
    Myriad Rocker
    The ability to speak does not make you intelligent

    I haven't had VB since college...go easy.

  13. #13

    Thread Starter
    Member
    Join Date
    Nov 2004
    Location
    Everywhere
    Posts
    46
    I got it figured out. Total time took a control array formula and the other two were just regular formulas.

    Total Time=IF(C2<>99,"",MAX(IF($B$2:$B$1043=B2,$G$2:$G$1043))-MIN(IF($B$2:$B$1043=B2,$E$2:$E$1043)))

    Total Time In Mins=IF(H2="","",H2*60*24)

    Down Time (Stop Mins)=IF(I2="","",(SUMIF($B$2:$B$1043,B2,$G$2:$G$1043)-SUMIF($B$2:$B$1043,B2,$E$2:$E$1043))*24*60)

    Thanks, though.
    Myriad Rocker
    The ability to speak does not make you intelligent

    I haven't had VB since college...go easy.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Ok, does it work if the rows change and does it work across multiple groupings?

    Looks like your getting sums for the whole sheet? 2 - 1043 rows?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width