+ Reply to Thread
Results 1 to 3 of 3

VBA to sort and group data together

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2012
    Posts
    4

    Question VBA to sort and group data together

    Hi all,

    I have the attached spreadsheet.

    Sheet 1 contains the current data I have. Sheet 2 contains how I wish to have presented with the help of a macro.

    Basically I want the data to be grouped by CPT ID, after the grouping, I want the data to be sorted by the STD earliest to latest, whilst maintaining the grouping.

    You will see in Sheet 2 the difference.

    Data will be completely different each day.

    Look forward to the help.

    Thanks
    Hayden

    fltdata.xlsx

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,583

    Re: VBA to sort and group data together

    Pl see attached file with Macro.
    Attached Files Attached Files

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: VBA to sort and group data together

    If you first sort your data by STD and then by CPT ID (both times asending) you will get the lay out you wish. A short macro for doing so could be written perhaps like this.

    Please Login or Register  to view this content.
    If you just wish to sort your data on Sheet1 and not copy result to Sheet2 remove lines marked ' remove not needed

    Alf
    Last edited by Alf; 04-07-2014 at 07:42 AM.

+ 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. Sort Data By Group
    By DJCurtley in forum Excel General
    Replies: 3
    Last Post: 11-08-2013, 03:47 PM
  2. Macro to compare with group of data and sort accordingly
    By barath3_s in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2013, 08:39 AM
  3. [SOLVED] Sort, Separate, Group Data in Table?
    By nickv02 in forum Excel General
    Replies: 2
    Last Post: 05-31-2012, 03:23 PM
  4. Excel 2007 : *SOLVED* How to group and sort data?
    By joshrob in forum Excel General
    Replies: 14
    Last Post: 09-20-2011, 10:48 AM
  5. [SOLVED] Can I group data on different rows together and then sort the grou
    By Stephanie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-12-2005, 08:05 AM

Tags for this Thread

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