+ Reply to Thread
Results 1 to 5 of 5

Lookup, index, match ,address ??????

  1. #1
    Registered User
    Join Date
    11-24-2008
    Location
    UK
    Posts
    28

    Lightbulb Lookup, index, match ,address ??????

    Hello once again people Ok now, I no what I'm about to ask can be done using a macro and I probably could of written it in less time that it took me to write this post but I'm sure it could be done using worksheet functions? It's given me a real headache so would someone step up to the plate please?

    Problem is:

    I have a stock code 6815JJPV

    6815 being the true "code"
    JJ representing the size
    PV representing the material.

    When 6815JJPV is ordered it's copied to a sheet listing all outstanding jobs but the sheet fragments the full code into 6815JJ and PV in order to make the reporting on how much PV we are using easier. If you look at the attached workbook there is a small sample on sheet 1 of the outstanding jobs list. What I would like to be able to do is from another workbook type 6815JJPV into a cell and have the cell next to it - say "B1" look up 6815JJPV from the outstanding jobs sheet then return the PO No from column A. Now I no that things would be easy if the full code wasn't fragmented, they would also be easy if there was another column using the "&" symbol to join the strings thus giving a full code to just run INDEX(MATCH on but that isn't the case sadly and they wont let me change the layout of things so, I'm trying to stealth around all the crap to make my job easier... I hope all this makes sense?

    By the way I did also think about using the LOOKUP function and the ADDRESS function but it gets tricky because it more often that not the case that same item will be ordered in 2 or 3 different materials which could lead to the PO No for 6815JJWV being returned because it is positioned lower in the list that 6815JJPV. What this function would really have to do in short is lookup 6815JJ then if the material next to it is PV obtain the PO No in column A. And like I said I no I could of written a macro by now lol but all these functions feel so close to what I need - I can't help but think it IS possible but I just don't no how ....


    And if one of you comes back with a really simple short answer I'll be gutted hahahah

    Thanks in Advance ! - James
    Attached Files Attached Files
    Last edited by James_C; 07-31-2009 at 09:10 AM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719

    Re: Lookup, index, match ,address ??????

    Hello James, for your example try this formula in C19

    =LOOKUP(2,1/((F2:F10=LEFT(C18,6))*(G2:G10=RIGHT(C18,2))),A2:A10)

    another way would be using this formula

    =INDEX(A2:A19,MATCH(C18,F2:F10&G2:G10,0))

    Although this second one is shorter it needs to be "array entered", i.e. confirmed with CTRL+SHIFT+ENTER so that curly braces appear around the formula in the formula bar.

    For your example both formulas will give the same result, although, theoretically they could give differeent results if you had 2 rows which matched the criteria (LOOKUP version gives the last matching row, INDEX/MATCH the first......)

    Edit: also an extra INDEX function can be used in the 2nd version.....this just obviates the need for CSE, i.e.

    =INDEX(A2:A19,MATCH(C18,INDEX(F2:F10&G2:G10,0),0))

  3. #3
    Registered User
    Join Date
    11-24-2008
    Location
    UK
    Posts
    28

    Re: Lookup, index, match ,address ??????

    Daddy your awsome !

    This is the second time I've seen the LOOKUP(2,1/ used and it makes no sense to me at all also the * in the middle says maths to me but I guess its nothing to do with multiplication.. I've also seen DonkeyOte use an & symbol which I also don't get.... I kinda see wear your going with INDEX(MATCH(INDEX - inspired! but I'm not here just for a copy /paste answer - I really want to get to grips with stuff like the lookup function VLOOKUP seems to be a walk in the park when I compare it to they things you guys do with LOOKUP but maybe I'm just not exploiting its full potential? Excel doesn't offer much help on the syntax front as far as I can see when it come to LOOKUP(2,1/(...)* OR &( ...) etc Is their any "easy" way these kind of function can be broken down ?? - Thanks so much - James

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719

    Re: Lookup, index, match ,address ??????

    Simple one first.....

    Using & in F2:F10&G2:G10 is just concatenating the data as you suggested, it's just that doing it this way you concatenate within the formula only rather than having to use an extra column on the worksheet.

    The LOOKUP version is a little more complex.....

    The * is indeed multiplication, when you have this test:

    F2:F10=LEFT(C18,6)

    it generates an array of TRUE/FALSE values, i.e. for your example

    {TRUE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE}

    and for G2:G10=RIGHT(C18,2) you get

    {TRUE;TRUE;TRUE;FALSE;TRUE;FALSE;TRUE;TRUE;TRUE}

    When these are multiplied TRUE is co-erced to 1 and FALSE to 0, and when the arrays are multiplied that means you get zeroes unless both elements are TRUE, in which case you get 1, so multiplying those gives

    {1;0;0;0;0;0;0;0;0}

    [notice the 1 is for the only row where both conditions are satisfied]

    Placing this in the LOOKUP formula I suggested we now have it simplified as far as this

    =LOOKUP(2,1/{1;0;0;0;0;0;0;0;0},A2:A10)

    When 1 is divided by an array of 1/0s then you get an array of 1/#DIV/0!s, i.e.

    =LOOKUP(2,{1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!},A2:A10)

    Now the next part exploits a "flaw" in LOOKUP. When you lookup a value (in this case 2) which is greater than every number in the array it matches with the last number (it should match with the greatest number but because the lookup array is meant to be sorted ascending excel assumes that the greatest number is the last).

    Of course in this case there's only 1 number (the errors are ignored) and the match is with the single 1 (as I said in my first post, if there are multiple matching rows then LOOKUP will return the last).

    This is the vector form of LOOKUP (see Excel help) whereby the lookup value matches within the first vector and the corresponding value is returned from the second, in this case that means that the match is with the 1 which is the first element of the first vector, so the returned value is the first element of the second vector, i.e. A2:A10 so A2 is returned......

  5. #5
    Registered User
    Join Date
    11-24-2008
    Location
    UK
    Posts
    28

    Re: Lookup, index, match ,address ??????

    Wow this is interesting. About 5 years ago I started A Cisco CCNA only got half way through, lost my job in a bar , couldn't afford the other half so dropped out But wot I'm getting from your reply is the vector ranges are tested cell by cell against the criteria either horizonatally or vertically depending on their orientation and you get a boolean true / false as you said, but booleans are also equal to 1 or 0 true false on off etc which brings me round to semester 1 of my CCNA - calculating Subnets and their masks etc. Am i rite in saying the boolean 1's and 0's are AND'ed ? producing the 1+ (or in this case*) 1=1 result? I think I may be off point but I feel I grasp it better now. I would love to sit down with people like you and get all this talked through ... I guess thats called college hahaha
    Last edited by James_C; 07-31-2009 at 09:07 AM. Reason: typo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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