+ Reply to Thread
Results 1 to 9 of 9

Merge colums from separate sheets and output unique distinct sorted list to third sheet

  1. #1
    Registered User
    Join Date
    11-02-2014
    Location
    Oregon
    MS-Off Ver
    2007/2010
    Posts
    13

    Merge colums from separate sheets and output unique distinct sorted list to third sheet

    So its been a few day since my first post which may have been a case of to much information. So I will approach my problem from a different angle and try to resolve one piece of the puzzle at a time.

    I really expected to find the answer after extensive searches of numerous forums as this is easy to solve with a formula. I can post my working formulas if anyone wants to see them. Unfortunately the load on the system with all the formulas requires a VBA solution.

    I have the following VBA. This code indexes the source sheet/column and copies a unique distinct list to the target sheet/column. Works great, automates the process and removes a bunch of very slow formulas. I change this up as needed, name, source ranges, target ranges and fire it off with a button with this code
    Please Login or Register  to view this content.
    As the source data is already sorted I have not needed to sort the output, but combining two columns adds that requirement.

    Please Login or Register  to view this content.
    How to modify this to index two columns on two sheets, and create a unique distinct list preferably sorted. Don't let the sub name "Dates" throw you. The data could be names, dates or numbers.


    2to1.jpg

    Any help would be appreciated as I have been searching and trying code for a while now.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Merge colums from separate sheets and output unique distinct sorted list to third shee

    I think in this instance, unless the dictionary is a requirement, that just setting ranges equal to each other is a better approach. Then just use excel's built in sort and remove duplicate features because they're there, so why not.

    If you still want to use the dictionary, just set your "a" range, run the for loop, set your "a" range again, run the for loop. That would at least have the built in advantage of not having any duplicates already.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-02-2014
    Location
    Oregon
    MS-Off Ver
    2007/2010
    Posts
    13

    Re: Merge colums from separate sheets and output unique distinct sorted list to third shee

    Your solution is brilliant. The data extraction is near instantaneous, compared to a formula that was taking 10 or 15 seconds.

    You have solved what days of research was unable to answer. Many many thanks.

    Would it be difficult to add a criteria to only return values from the above query that matched the designated criteria. Such as only return values where column x=Z2 for Blue?

    2to1crit.jpg

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Merge colums from separate sheets and output unique distinct sorted list to third shee

    Sure, but I would use a completely different approach.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-02-2014
    Location
    Oregon
    MS-Off Ver
    2007/2010
    Posts
    13

    Re: Merge colums from separate sheets and output unique distinct sorted list to third shee

    You are a lifesaver

    I am setting it up now. Is it possible to set the criteria to reference a sheet and cell number instead of "blue". I expect this variable to change as I am using the earlier VBA to populate these and other values.

    Such as...

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Merge colums from separate sheets and output unique distinct sorted list to third shee

    Sure.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-02-2014
    Location
    Oregon
    MS-Off Ver
    2007/2010
    Posts
    13

    Re: Merge colums from separate sheets and output unique distinct sorted list to third shee

    It working great with the updated search for string. It sorts dates ok, but when I query a column with names the sort is a bit jumbled. All the data is present just not sorted correctly.

    Should I use a different sort method or orientation for names?

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-02-2014
    Location
    Oregon
    MS-Off Ver
    2007/2010
    Posts
    13

    Re: Merge colums from separate sheets and output unique distinct sorted list to third shee

    I was able to correctly sort the output by selecting the sort button from the toolbar and choosing sort ascending. Anyone know if this will be persistent? Really need other users who view the workbook to see this data as sorted ascending.

  9. #9
    Registered User
    Join Date
    11-02-2014
    Location
    Oregon
    MS-Off Ver
    2007/2010
    Posts
    13

    Re: Merge colums from separate sheets and output unique distinct sorted list to third shee

    Sorry to be so persistent. Using the sort function induces a run time error 1004. The sort reference is not valid.

    This error is generated using both versions of the function. The combine two function and the combine two with criteria.

    Both functions are working well to extract the data from two columns and remove duplicates with or without criteria. When it lists the data it sorts the first source ascending, then sorts the second source ascending. This is easy to see when extracting date data. Although it happens with names as well.

    First data set extracted
    a
    c
    e
    Second data set extracted
    b
    d
    f

    Displays as
    a
    c
    e
    b
    d
    f

    Any fix for this?

    should be
    a
    b
    c
    d
    e
    f
    Last edited by mrmattmc; 11-06-2014 at 12:35 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. 2 Sheets - Input Sheet & Output Sheet - Find unique number and add value to a column
    By bebongtheshark in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-16-2014, 01:23 AM
  2. [SOLVED] Unique distinct alphabetically sorted list
    By atlant15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2013, 10:03 AM
  3. Sorted data on separate sheets
    By Wibs in forum Excel General
    Replies: 5
    Last Post: 10-30-2011, 02:53 PM
  4. Replies: 10
    Last Post: 09-27-2011, 03:40 PM
  5. Replies: 0
    Last Post: 01-14-2010, 04:33 PM

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