+ Reply to Thread
Results 1 to 11 of 11

Macro to sort data into totals & %'s

Hybrid View

  1. #1
    Registered User
    Join Date
    07-24-2007
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    80

    Re: Macro to sort data into totals & %'s

    Thanks Foxguy for your quick response. A couple of things:

    1/ When adding up the total number of trains for each HC, if Column L is blank, do not count these as part of total, only cells with a number in.
    2/ I made an error about the definition of trains 'on time'. It is any train arriving 10 minutes or less, which includes negative numbers, which are in fact arriving early.
    3/ Any entry in HC (column B) starting with '0' not to be included in totals (if that's too difficult don't worry about it).

    Thanks again for your help. Kevin.
    Last edited by rushdenx1; 06-04-2010 at 05:46 PM.

  2. #2
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro to sort data into totals & %'s

    Kevin;

    I abhor ever deleting data, so I left it alone, just didn't count it.
    Try this file Copy of Performance Data Dump1-2.zip I didn't debug it at all. Didn't have time. If it has a bug, it'll have to wait until tomorrow.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  3. #3
    Registered User
    Join Date
    07-24-2007
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    80

    Re: Macro to sort data into totals & %'s

    Thanks Foxguy. Everything looks good.

    One last request. The 'ran', 'on time' and '% on time' has been done for each HC. Can this also be done for each ORIGIN (column F). This will then give me the number of journeys from each location and their 'on time' and '% on time' figures. On thing to bear in mind is that some locations appear under more than one 'lettered' tab. 'Port of Tyne' as an example appears under 'F' tab and 'N' tab. I would like a separate total under each tab for each location.

    Thanks again. That will complete my request. Kevin.

  4. #4
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro to sort data into totals & %'s

    Kevin;
    One last request. The 'ran', 'on time' and '% on time' has been done for each HC. Can this also be done for each ORIGIN (column F). This will then give me the number of journeys from each location and their 'on time' and '% on time' figures. On thing to bear in mind is that some locations appear under more than one 'lettered' tab. 'Port of Tyne' as an example appears under 'F' tab and 'N' tab. I would like a separate total under each tab for each location.
    It can be done. The easiest way would be to re-sort the data for Origin on each tab, then count for each Origin, the same way HC was counted. Would you want data on each sheet sorted by HC or Origin when it's done?

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro to sort data into totals & %'s

    Kevin;

    Try this file Copy of Performance Data Dump2.zip

  6. #6
    Registered User
    Join Date
    07-24-2007
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    80

    Re: Macro to sort data into totals & %'s

    That's great. When it's done the data on each sheet wants to be sorted by HC. Thanks Kevin

  7. #7
    Registered User
    Join Date
    07-24-2007
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    80

    Re: Macro to sort data into totals & %'s

    Apologies for this. I have just realised that I need the 'ran', 'on time' and '% on time' data for each DESTINATION aswell. Hopefully this is similar to what's already been done for ORIGIN, so won't cause too much work.

    I have included an updated file.

    Thanks again and apologies for the extra request. Kevin.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro to sort data into totals & %'s

    Kevin;

    Sorry, I've been away for a few days. Here's a new file Copy of Performance Data Dump3.xls.
    I changed the name of the sub that counts. You can call it as many times as you want.
    Count_Column sh, "G", "AB", iLastColumn
    sh is the sheet that is getting counted
    "G" is the column you want counted
    "AB" is the column where you want the results stored.
    iLastColumn is a variable that stores the last column used, so that the FormatFilterSortAndPasteToSheet() can autofit enough columns
     
               Count_Column sh, "G", "AB", iLastColumn
               Count_Column sh, "F", "W", iLastColumn
               Count_Column sh, "B", "R", iLastColumn
               .Range(.Cells(1, 1), .Cells(1, iLastColumn)).EntireColumn.AutoFit
    Just make sure that the last call to Count_Column() is the order that you want the sheet to be left in.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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