+ Reply to Thread
Results 1 to 23 of 23

Is this an array usage or is an array necessary?

  1. #1
    Registered User
    Join Date
    04-04-2013
    Location
    Longview, TX
    MS-Off Ver
    Excel 2010
    Posts
    12

    Is this an array usage or is an array necessary?

    I have a quandary and I'd like to know how to pull this off. First here's the setup...

    I have a large data set with thousands of rows of records that have to do with sales people, their sales, sales per item, etc.

    In a second much smaller data set I have the employee records showing the sales people and what region they are from.


    I want to filter the big list to show all sales records for sales people from region II. This may be 5 or 6 sales people.

    Now, using advanced filtering, if I knew the names of these people, I could just list the 5 or 6 names in the criteria range and the big range would display only those names.

    What I want to do is to somehow lookup the names of all region II sales people from the little employee range and have that list of 5 or 6 people populated in the "names" column of the criteria range as if I had manually entered them myself.

    So I need something that will lookup and return a list of names and then enter that list into the criteria range.

    I think vlookup only returns one result.

    Is there anyway to return a list and have that list inserted some other place like the criteria range that can then be used to filter the big range?

    tex
    Last edited by thetexan; 11-13-2015 at 01:14 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Is this an array usage or is an array necessary?

    Why don't you do it the other way round? Add a helper column to the big list and put the VLOOKUP in there to search for the employee and return the region.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-04-2013
    Location
    Longview, TX
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Is this an array usage or is an array necessary?

    Let me ask it this way...

    Usually there is one formula in one cell that returns one result In That cell.

    Is there a way for one formula in one cell to return a list of multiple results in multiple cells??

    For example...I enter some formula in one cell and I get (say) a list of 30 items in thirty cells?

    Tex

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Is this an array usage or is an array necessary?

    It would help if we could see a sample wf what you have and what you want, but see if this will get you started (if I understand you properly)...
    A
    B
    C
    D
    E
    F
    1
    Name Item Rates Unit Name1
    2
    name1 Item 1
    18
    m2 Item 1
    3
    name1 Item 2
    16
    m2 Item 2
    4
    name1 Item 3
    15
    m2 Item 3
    5
    name1 Item 4
    2
    m2 Item 4
    6
    name 2 Item 1
    36
    m2
    7
    name 2 Item 2
    30
    m2
    8
    name 2 Item 3
    30
    m2
    9
    name 2 Item 4
    28
    m2
    10
    name 3 Item 1
    26
    m2
    11
    name 3 Item 2
    38
    m2
    12
    name 3 Item 3
    34
    m2
    13
    name 3 Item 4
    32
    m2

    F2=IFERROR(INDEX($B:$B,SMALL(IF($A$2:$A$13=$H$2,ROW($A$2:$A$13)),ROWS($A$1:A1))),"")
    copied down.

    this ia an ARRAY formula...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Is this an array usage or is an array necessary?

    I imagine that someone here could come up with an array formula that might do that. But not me.

    Personally, I'd look to make the data a Structured Table and then use the filtering and sorting to view the records you are interested in

    But, if you're just going to drip feed information with no real detail, it will take forever to find a solution for you.

    I suggest that you upload a sample workbook that accurately represents the live file but wit a limited subset of records with any sensitive data removed. If you also provide a mock up of what you hope to see based on the sample data, it will encourage people to offer solutions.

    Bear in mind that if you have a small list of, say, hundreds of records, processed against a large list of, say, thousands of transaction, any array formula based solution is likely to be very processor heavy.

    What do you plan to do with the data? Would a Pivot Table not be a better option?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Is this an array usage or is an array necessary?

    @Ford: hat's in H2 to get that?

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Is this an array usage or is an array necessary?

    @ TMS...hat's? (that's?)
    I didnt show column H?
    What am I missing lol

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Is this an array usage or is an array necessary?

    Hat's off ... should have been what's . Your formula refers to cell H2. Just wondered what' sin it?

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Is this an array usage or is an array necessary?

    aahh gotcha, good catch.

    H2 contained Name1

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Is this an array usage or is an array necessary?

    Woulda been better if it was NAME2 or NAME3. It looks like you just copied them across

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Is this an array usage or is an array necessary?

    Maybe this will make it clearer

    A
    B
    C
    D
    E
    F
    G
    H
    1
    Name Item Rates Unit Name1
    2
    name1 Item 1
    18
    m2 Item 5 name2
    3
    name1 Item 2
    16
    m2 Item 6
    4
    name1 Item 3
    15
    m2 Item 7
    5
    name1 Item 4
    2
    m2 Item 8
    6
    name2 Item 5
    36
    m2
    7
    name2 Item 6
    30
    m2
    8
    name2 Item 7
    30
    m2
    9
    name2 Item 8
    28
    m2
    10
    name3 Item 9
    26
    m2
    11
    name3 Item 10
    38
    m2
    12
    name3 Item 11
    34
    m2
    13
    name3 Item 12
    32
    m2

    F2=IFERROR(INDEX($B:$B,SMALL(IF($A$2:$A$13=$H$2,ROW($A$2:$A$13)),ROWS($A$1:A1))),"")
    ARRAY entered

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Is this an array usage or is an array necessary?

    Yep. Apart from the NAME1 in F1. What's that about then

  13. #13
    Registered User
    Join Date
    04-04-2013
    Location
    Longview, TX
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Is this an array usage or is an array necessary?

    Here is what I'm getting at...


    FINAL1.jpg

    I want to enter a formula in A2 (I think, this is where I'm not sure) that will lookup all region 2 employees by name in the employee dataset then send those names in the form of a list and populate them in A2 and downward in an advanced filter criteria range without me having to type all of the names in the criteria list manually.

    Thusly...

    final2.jpg

    Both of the data sets will be hundreds and thousands of lines long so it needs to be automated with a formula. In the end I want to advance filter the sales data set and display only region 2 employees.

    tex

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Is this an array usage or is an array necessary?

    @tex: you know all the trouble you went to to make the pretty pictures of your sample workbook? Yes, well, much better to post the actual workbook

  15. #15
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Is this an array usage or is an array necessary?

    Quote Originally Posted by TMS View Post
    Yep. Apart from the NAME1 in F1. What's that about then
    It's just a heading :0

  16. #16
    Registered User
    Join Date
    04-04-2013
    Location
    Longview, TX
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Is this an array usage or is an array necessary?

    ok, here is the workbook...
    Attached Files Attached Files

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Is this an array usage or is an array necessary?

    Try these...
    A2=IFERROR(INDEX($A:$A,SMALL(IF($H$9:$H$22=2,ROW($A$9:$A$22)),ROWS($A$1:A1))),"")
    ARRAY entered
    B2=IF($A2="","",INDEX($B$9:$D$21,MATCH($A2,$A$9:$A$22,0),MATCH(B$1,$B$8:$D$8,0)))
    copied across

    Then copy them all down as needed

  18. #18
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Is this an array usage or is an array necessary?

    In your criteria range under Name enter this Array formula and fill down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I assigned H2 to be the region that you want to extract records from.
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  19. #19
    Registered User
    Join Date
    04-04-2013
    Location
    Longview, TX
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Is this an array usage or is an array necessary?

    Thank you for the idea and formula. I think that will solve the problem.

    I still would like an answer to the other question I have. Here it is again.

    Each of the above solutions require "and fill down" requiring a manual effort on my part to populate the formula for each cell below.

    I'm not looking for a formula here just a yes or no answer if possible.

    Whether on this subject or any other subject...is it possible to enter some formula into a single cell which results in a list of, say, 20 (for example) items each of which is populated into individual cells...for example...a formula in A1 which looks up something in a data set then sends the 20 results it finds into cells B1:B20.

    Alternatively...is there a way (again yes or no) to enter a formula which retrieves a list of data where those 20 items are in the form of an array which can, in a second single step, be distributed into cells B1:B20.

    As I stated earlier, it seems that in excel you enter one formula per cell (either manually or by filling down) and get one result per cell. I haven't seen where you enter a single formula into one cell which can result in a list of items which can be placed in numerous cells.

    One thing that came to mind was if I used some lookup that looks up something, ie find all occurances of "Tom" then place each of his phone calls into cells B1:Bwhatever, where each time the lookup found an occurance it placed it into B1, then incremented the row to B2 waiting for the next occurance, and so on.

    I hope I'm explaining myself adaquately. I'm not sure how to even phrase the question. This is the kind of thing I'm looking for. I just want to know if it's possible (auto incrementing of rows, etc) and if it is can you please point me in the right direction and I will do my homework and study it. I just don't know where to look.

    thanks,
    tex
    Last edited by thetexan; 11-14-2015 at 12:40 PM.

  20. #20
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Is this an array usage or is an array necessary?

    Since you want a simple answer, No, excel doesn't do that. It's one formula, one answer

  21. #21
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Is this an array usage or is an array necessary?

    @thetexan,

    What you would usually do is to copy the formula down as many cells as you expect in the worse case, and arrange for the formula to return blanks if there is no more matching data. Within the formula you would make use of a term like ROWS($1:1), which increments as it is copied down.

    Hope this helps.

    Pete

  22. #22
    Registered User
    Join Date
    04-04-2013
    Location
    Longview, TX
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Is this an array usage or is an array necessary?

    Perfect. I will quit looking for something that doesn't exist. Incrementing will be the way to go I suspect.

    Thanks

  23. #23
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Is this an array usage or is an array necessary?

    If that takes care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

+ 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] Populate one array from another array and print new array as a range
    By Kaden265 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2014, 07:52 AM
  2. [SOLVED] Quick Array question - Copy array to another array then resize?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-02-2013, 01:17 AM
  3. DIR function AND ARRAY usage?!
    By lgiannetti in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-14-2011, 06:34 AM
  4. Array usage
    By brocklanders in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2006, 10:15 PM
  5. Can anyone shorten this one. (not overly clear on array usage)
    By Down'd Pilot in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-03-2006, 10:45 AM
  6. Replies: 3
    Last Post: 09-08-2005, 12:53 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