+ Reply to Thread
Results 1 to 7 of 7

Sort Query Results to remove duplicate entries and put results on one line.

  1. #1
    Registered User
    Join Date
    04-28-2015
    Location
    Dallas, TX
    MS-Off Ver
    2007
    Posts
    3

    Sort Query Results to remove duplicate entries and put results on one line.

    Hello and Thank you in advance.

    I wrote a vba script that runs an SQL query that gives me a list of all the parts we have in stock and where they are located. I need to be able to sort them so that a part is only listed once and all the locations are listed on that row next to the part number. Sometimes there is only one location. Sometimes, there are up to 26 locations.

    My main approach was to sort the parts in order and use a for loop to check for matches and to use relative references to move the found locations up, but I haven't been able to get that to work.

    I've tried everything I can think of and I'm getting no where. I've attached what a sample parts list would look like (sheet1) and how I need to have it sorted (sheet2). I'm not asking for anyone to write this for me. I just need some advice as to what direction I need to head in.

    Thank you for your time and consideration.
    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: Sort Query Results to remove duplicate entries and put results on one line.

    Hi Panther

    Welcome to the Forum!!!

    Do you care what order the Locations are in going horizontally across the worksheet?
    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
    04-28-2015
    Location
    Dallas, TX
    MS-Off Ver
    2007
    Posts
    3

    Re: Sort Query Results to remove duplicate entries and put results on one line.

    Thank you for the welcome and response. I've learned a lot here and I appreciate all that is done to help the members of these forums.

    No. The order isn't important. It would be okay to just list them in the order they are found after the original sort.

  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: Sort Query Results to remove duplicate entries and put results on one line.

    Hi Panther

    Try this Code in the attached...CTRL + x will fire the Code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-28-2015
    Location
    Dallas, TX
    MS-Off Ver
    2007
    Posts
    3

    Re: Sort Query Results to remove duplicate entries and put results on one line.

    Wow. That's perfect. Thank you so much for your help.

  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: Sort Query Results to remove duplicate entries and put results on one line.

    Hi Panther

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

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

    If this resolves your issue please mark your Thread as SOLVED.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  7. #7
    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: Sort Query Results to remove duplicate entries and put results on one line.

    Hi Panther

    I'm looking at the Code and two lines of Code should be changed (in two places)...
    Please Login or Register  to view this content.

+ 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. [SOLVED] MultiLine Textbox to auto remove blank line, count line, remove duplicate
    By khhoa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-24-2015, 09:28 PM
  2. [SOLVED] Sort results of INDEX/MATCH array formula remove blanks. . .
    By PeteABC123 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-14-2014, 01:53 PM
  3. Query results on subform updated but old results stilled displayed
    By menmine5 in forum Access Tables & Databases
    Replies: 1
    Last Post: 09-29-2013, 02:37 AM
  4. Replies: 1
    Last Post: 02-22-2012, 09:01 AM
  5. Replies: 3
    Last Post: 03-31-2010, 11:47 AM

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