+ Reply to Thread
Results 1 to 6 of 6

How to filter through multiple “Arrays” at once?

  1. #1
    Registered User
    Join Date
    10-21-2016
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    2

    How to filter through multiple “Arrays” at once?

    I am attempting to write a sub that'll go through the two given arrays, "customers who purchased last year" and "customers who purchased this year" and create THREE arrays; "who bought last year," "who bought this year," and "bought in either year". Since the two given lists have names who bought in both years, I am struggling to differentiate between the two into separate arrays. So far the Code successfully achieves the array "bought in either/both years," yet I'm unable to achieve the other 2 and separate. Any advice on where I'm going wrong would be greatly appreciated. Thank you!

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    10-19-2012
    Location
    Omaha, Nebraska USA
    MS-Off Ver
    Excel 2010
    Posts
    249

    Re: How to filter through multiple “Arrays” at once?

    Hi Vedant29,

    The code below should separate the data in list1 and list2 once they are populated.

    Please Login or Register  to view this content.
    Hope that helps,

    Dan
    Last edited by djbomaha; 10-22-2016 at 12:56 AM.

  3. #3
    Registered User
    Join Date
    10-21-2016
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    2

    Re: How to filter through multiple “Arrays” at once?

    Hi Dan

    Thank you so much for the reply, I tried to include your code and run it, but it gives me an error on "ReDim Preserve list4(listSize4) As Variant". the error reads "Can't change data types of array elements". Also could you please explain what does "GoTo 200" and "GoTo 100" mean in your code as I'm unable to understand it.

    Thanks
    Vedant

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to filter through multiple “Arrays” at once?

    Try this.



    Please Login or Register  to view this content.
    Those LBounds can be replaced with the constants that you are working with.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Forum Contributor
    Join Date
    10-19-2012
    Location
    Omaha, Nebraska USA
    MS-Off Ver
    Excel 2010
    Posts
    249

    Re: How to filter through multiple “Arrays” at once?

    It is giving the error because I had it defined as Variant rather than a String. I edited the code I posted so the arrays are defined as Strings.

    The goto 100 line is in the portion of the code when it is populating the only last year array. It is checking list1 against list2 and if the value in list1 matches the value in list2, then it skips to the next value in list1. If none of the values in list2 match list1, then it puts the value of list1 in list4.

    The goto 200 line is in the portion of the code when it is populating the only this year array. If the value of list2 in in list1, then it skips to the next value of list2 by going to line 200.

  6. #6
    Forum Contributor
    Join Date
    10-19-2012
    Location
    Omaha, Nebraska USA
    MS-Off Ver
    Excel 2010
    Posts
    249

    Re: How to filter through multiple “Arrays” at once?

    It is giving the error because I had it defined as Variant rather than a String. I edited the code I posted so the arrays are defined as Strings.

    The goto 100 line is in the portion of the code when it is populating the only last year array. It is checking list1 against list2 and if the value in list1 matches the value in list2, then it skips to the next value in list1. If none of the values in list2 match list1, then it puts the value of list1 in list4.

    The goto 200 line is in the portion of the code when it is populating the only this year array. If the value of list2 in in list1, then it skips to the next value of list2 by going to line 200.

+ 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. storing multiple value in a single cell (through arrays or without arrays)?
    By mak51061 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-25-2014, 09:27 PM
  2. COUNTIF(?) For Multiple Arrays With Multiple Conditions
    By MJ10 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-09-2014, 10:07 PM
  3. [SOLVED] Filtering Arrays using the filter function
    By Xrull in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2014, 12:47 PM
  4. Pivot table filter based on arrays and copy average data to another sheet
    By millatshawn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-14-2014, 05:33 PM
  5. Declaring multiple multi-dimensional arrays (jagged arrays) - compile error?
    By dfribush in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2013, 05:06 PM
  6. Using the auto-filter selection form on arrays
    By Perception in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-26-2011, 06:59 AM
  7. Using Arrays and IF Function to filter data
    By Denver in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-25-2008, 09:17 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