+ Reply to Thread
Results 1 to 7 of 7

Array function to look up multiple values

  1. #1
    Registered User
    Join Date
    03-25-2016
    Location
    Bay Area, California
    MS-Off Ver
    2013
    Posts
    5

    Array function to look up multiple values

    Hello,

    I'm currently working on getting this array function to work for me. Basically, I need it to pull specific items from a list based on a criteria. For instance, I have an excel report that i run weekly that lists different vendors' credits on account. These vendors are split among our sales people by state. So instead of copying and pasting each line (company A, California, $$$credit // company B, California, $$$credit // company c, Alabama, $$$credit) into each salesperson's excel worksheet, I'm trying to get it so I can pull them all at once. So for Alabama, California, and 4 others states that Bob controls, I can pull all those and paste it onto its own worksheet for Bob. That's the idea.

    Right now, what I have works, but only for one state at a time. I'm using

    Please Login or Register  to view this content.
    In the bold is the specific cells on the report. I keep them $locked.

    But it'd make my life way easier if I can include more than one state at a time. Otherwise, I'm copying and pasting the formula and changing it around for both the state and the column number (I already have to do the column changes at the very end of the formula to get 1-9 across the board).

    I've tried nesting IF formulas into it, I've tried choosing multiple cells for the IF criteria (for instance, IF(REPORT STATE COLUMN=$A$1:$A:$5,etc.)), but I'm just not having any luck with any of those. I'll either get a statement saying I have too many arguments or too few arguments. Does anyone have any insight on what I can do here? I'm worried that I might be entering VBA territory, which I have extremely limited knowledge of.

    Thank you.

  2. #2
    Registered User
    Join Date
    03-25-2016
    Location
    Bay Area, California
    MS-Off Ver
    2013
    Posts
    5

    Re: Array function to look up multiple values

    I can provide an attachment if that'll help anyone's understanding of what I'm trying to say... Does anyone have any suggestion at all?

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Array function to look up multiple values

    Have you tried sorting your data using autofilter?

    I can provide an attachment
    That would be a good idea as the way your data is set up will have an impact on how this problem could be solved.

    Alf

  4. #4
    Registered User
    Join Date
    03-25-2016
    Location
    Bay Area, California
    MS-Off Ver
    2013
    Posts
    5

    Re: Array function to look up multiple values

    Here's an example of what I'm going for
    Attached Files Attached Files

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Array function to look up multiple values

    The only way I could solve this was using a macro.

    There are a number of things to consider, two sheet names are "hard coded" in the macro, not good.

    Then there is the problem with the state names in the first sheet for instance "California" but in the second sheet you have both "California, North" and "California, South" so I've made a modified list but I'm not to happy about that. And there are a number of states like this in your data base but not in the data in sheet 1.

    Then are you going to do separte runs or do you plan to save old data and update with new?

    At the moment the macro deletes all previous sheets except the first two. It then adds the name of the sales representative in column K, makes a unique list of all the names and sets up an autofilter for each person.

    Result is copied to a sheet with sales representatives name. Have a look and see if this is something that you could use.

    To test run macro "FindRep"

    Alf
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-25-2016
    Location
    Bay Area, California
    MS-Off Ver
    2013
    Posts
    5

    Re: Array function to look up multiple values

    Alf,

    I really appreciate the help and the macro you've come up with.

    Yeah the list of territories for each rep can be a little troublesome. Modifying it was the right thing to do. Other than New York, the split states (California, North+South) are owned by the same rep. The report that I run from SAP doesn't know to split the states based on where the city is. That's something I can alter myself though.

    I plan on saving and emailing out the results once per week to the sales reps so they have a heads up on accounts with credits. So it'll be new data the next week.

    From what I can tell so far, the macro does exactly what I need it to. Thank you so much. My workaround was creating a new column to the left of the data provided and using an if(D2="Alabama","Bob Smith",if(D2="Alaska",...... etc. for every single state and rep. Then I set it up into a table and auto filtered to organize it. From there I copied and pasted each section into a worksheet for each rep. Same end result, just more of a workaround.

    Once again, thank you for helping me with this task, Alf. I will have to work on learning more about VBA and macros.

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Array function to look up multiple values

    You are welcome. If there are any modifications or if you do have questions about the macro don't hesitate to ask.

    If you are going to mail the results every week then perhaps one could have a third sheet as a template and just let the maco fill in the relevant data in order to get a more "professional" looking report?

    Alf

+ 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. Pull sub array from array using multiple column_num values
    By SinJinQLB in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-25-2015, 05:37 PM
  2. [SOLVED] multiple values in an array
    By PeterJohns in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-30-2014, 07:42 PM
  3. How to use SUMPRODUCT or other function to SUM array of values
    By netgroover in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-11-2013, 09:06 PM
  4. Find a value in an array and return multiple values in an adjacent array
    By tonbra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2012, 08:35 PM
  5. Passing a whole set of values of an array to a function
    By PaulLag in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-28-2012, 06:08 PM
  6. Assigning values into array using the "Array" vba function.......not working
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-17-2011, 04:21 PM
  7. how to pass array values to function
    By exceltools2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-10-2008, 09:39 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