+ Reply to Thread
Results 1 to 14 of 14

Combine arrays

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Combine arrays

    Hi,

    I have 4 worksheets. On each worksheet there is one column of data that i am interested in. Each of teh cols has a different header but they contain the same type of data. In this case the data is Lot-ID.

    What i want to do is combine all 4 cols into a single array and then using this array come up with a unique list of Lot-IDs. I know how to assign a single col to an array but i am not sure the best way to take 4 cols from 4 different worksheets and put them all into a single array.

    any thoughts?

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: combine 4 arrays into one...........how to.....is this even best way

    Try this, all you need is to combine the data in a single unused column and then remove duplicates, then add the range to an array.

    Please Login or Register  to view this content.
    Please take time to read the forum rules

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: combine 4 arrays into one...........how to.....is this even best way

    very interesting..........i had not even considered this approach at all. Let me take a look at this..........not familiar with some of this so let me review.........looks like it will work. let me take a look at it. thanks.

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Combine arrays

    finally getting around to looking at this more. Had some other things come up but now i am going to work on this. I did have one question and if its not easy i will try and figure out a way myself.

    So i mentioned i had 4 worksheets and i have one col of data from each of the 4 worksheets and that i was trying to get a unique list of the combined 4 cols. Well, i am but i just learned that its really two cols per worksheet......for a total of 8 cols.

    So for example: I have Person-ID and Lot-ID as the two cols in each file and i am trying to find the unique list of (Person-ID + Lot-ID) ........not just Lot-ID as i mentioned before.

    So using the code i am not sure how yet but i guess i need to combine the two cols into one and then use the code provided then some how "de-couple" the finalized unique col into two cols.......

  5. #5
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Combine arrays

    You dont need to combine and split again

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Combine arrays

    cool! i will try it out now.........many many thanks!!!!!!!!!!!!

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combine arrays

    Please Login or Register  to view this content.
    NB. probably the only thing to adapt: range "A1:D8"
    Last edited by snb; 12-01-2011 at 10:05 AM.



  8. #8
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Combine arrays

    i cant seem to get the remove duplicates part to work correctly.

  9. #9
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Combine arrays

    What happens when you run the code?

  10. #10
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Combine arrays

    Recall that i have two columns (Person-ID and Lot-ID).

    So i want only unique combinations of PersonID and LotID. FYI: PersonID is in colA and LotID in colB.

    What its giving me is the unique entries for colB only.

  11. #11
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Combine arrays

    i am enclosing a test file...............run the macro ......only the unique entries in col B are whats left after you run the macro.

    As it turns on in the example i provided.........i think every entry such that the combination of ColA+ColB is a unique entry in the list.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Combine arrays

    anyone still there?

  13. #13
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Combine arrays

    i dont think using this removeduplicates is going to work as hoped. I could create a 3rd column of values which is a concatenation of the first 2 and then remove duplicates based on this 3rd column......but at that point is it better just to put everything into arrays and do it via arrays?

  14. #14
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Combine arrays

    Hi,

    Im sure it can be done with faster code, but this works

    I have created 3 sheet with data in columns a and b, when you rund the code, sheet4 will be populated with uniquevalues.
    Attached Files Attached Files

+ 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