+ Reply to Thread
Results 1 to 6 of 6

Macro to sort variable rows of data by a column in multiple sections

  1. #1
    Registered User
    Join Date
    06-10-2013
    Location
    Hampton, VA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Macro to sort variable rows of data by a column in multiple sections

    I need a macro that will sort the data between columns A - O by column J in ascending order. To make it a little more complicated, the first and last rows are not defined. It depends on how much data is exported from a Crystal Report. It could be 1 row of data to 30 rows of data. And it will be 3 separate sections of rows. So for the last 2 sections the first row varies by how many rows are in the first section. I attached the spreadsheet so you can see what I am talking about.
    When I export this report to Excel, rows 1 - 3 will always be the same. The data in the rows under P1 Level Calls sub heading will vary on how many calls there were that day, but the first row for that section will always be row 4. Then the "Total # P1 Calls" row will always be at the end of that section. Then there are 2 empty rows, then The NCR CE Meet section and a varying about of rows for that data underneath, then the 3rd section "NCR On Site" under that with varying rows of data. I need the macro to sort the sections of rows by column J in ascending order, then highlight the rows where it says "Missed" in column J. Is this possible?
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro to sort variable rows of data by a column in multiple sections

    Hi mannuhs

    You posted an .xls file but your profile shows Excel 2007. Does the required Code need to work in only Excel 2007 and later or does it also need to work in earlier versions?
    Last edited by jaslake; 06-10-2013 at 07:18 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    06-10-2013
    Location
    Hampton, VA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro to sort variable rows of data by a column in multiple sections

    I use Excel 2007, but this particular file I save in xls. format because I distribute it to others. If the code just works for 2007 that's fine. I can just save the file in an earlier format before I distribute it.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro to sort variable rows of data by a column in multiple sections

    Hi mannuhs

    Sort syntax is different for Excel 2007. This syntax will work in either. You indicated to sort through Column O but your Data extends to Column R so that's what I used. If you truly want Column O change the rng references.
    Let me know of issues.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-10-2013
    Location
    Hampton, VA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro to sort variable rows of data by a column in multiple sections

    Wow that worked perfect! Thanks so much!

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro to sort variable rows of data by a column in multiple sections

    You're welcome...glad I could help.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Thanks.

+ 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