+ Reply to Thread
Results 1 to 11 of 11

Vlookup help

  1. #1
    Registered User
    Join Date
    02-28-2012
    Location
    Kolkata
    MS-Off Ver
    Excel 2007
    Posts
    35

    Vlookup help

    Hi Excel Gurus,

    I am stuck in a situation where I am not being able to express my problem correctly. Let me try this once.

    I have this file where I have some POs in column A of sheet1, I need to get the tracking infos from sheet2. I can use vlookup but the problem is that I have all the PO in format "TKO-247" in sheet1 where as in sheet2 the PO can be in any cell of column A and anywhere also the format can be "TKO/247", "TKO 247", "TKO247".

    I hope I was able to make u understand.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: Vlookup help

    Hi Brajesh. This is not pretty or fast, but should do the trick.
    Please Login or Register  to view this content.
    Note that this has to be entered as an array formula (CTRL+SHIFT+ENTER)
    Also, when there is no match found it will display the value in the first row of column B.

    Good luck!
    Last edited by gjlindn; 06-15-2012 at 10:31 PM.
    -Greg If this is helpful, pls click Star icon in lower left corner

  3. #3
    Registered User
    Join Date
    02-28-2012
    Location
    Kolkata
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Vlookup help

    Quote Originally Posted by gjlindn View Post
    Hi Brajesh. This is not pretty or fast, but should do the trick.
    Please Login or Register  to view this content.
    Note that this has to be entered as an array formula (CTRL+SHIFT+ENTER)
    Also, when there is no match found it will display the value in the first row of column B.

    Good luck!
    Close enough, I must say.

    I thought it did the trick but suddenly have seen some results showing "0". Can u pls check once more.
    And yes, its really slow. It takes me around 15 minutes on my core2duo 1gb ram win 7 ultimate system.

    Thanks and appreciate ur effort anyways.

  4. #4
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: Vlookup help

    This is a little simpler but it does require listing each of the separators within curly brackets
    Please Login or Register  to view this content.
    Also, in order to increase speed, I've created a named range for the lookup range used. Thanks!

  5. #5
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: Vlookup help

    Or may be this with just ENTER,

    =IFERROR(INDEX(Sheet2!B:B,LOOKUP(2^20,MATCH("*"&SUBSTITUTE(A2,"-",{"","-","/"," "})&"*",Sheet2!A:A,0))),"N/A")
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  6. #6
    Registered User
    Join Date
    02-28-2012
    Location
    Kolkata
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Vlookup help

    Quote Originally Posted by gjlindn View Post
    This is a little simpler but it does require listing each of the separators within curly brackets
    Please Login or Register  to view this content.
    Also, in order to increase speed, I've created a named range for the lookup range used. Thanks!
    greg, dont know If i missed something but the result of this formula shows "#NAME".
    Sorry If i was not able to understand, a big noob here. :D

    Quote Originally Posted by Haseeb A View Post
    Or may be this with just ENTER,

    =IFERROR(INDEX(Sheet2!B:B,LOOKUP(2^20,MATCH("*"&SUBSTITUTE(A2,"-",{"","-","/"," "})&"*",Sheet2!A:A,0))),"N/A")
    Thanks Haseeb, that worked. I am yet to examine it fully but it seems to be perfectly ok. Will reply if I need further improvement here.
    Appreciate your effort.

  7. #7
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: Vlookup help

    Hi brajesh. In order to get mine to work you'd need to add a named range in column A of sheet2 and call it rngLookup. But use Haseeb's code...simpler and faster! Nice solution Haseeb!

  8. #8
    Registered User
    Join Date
    02-28-2012
    Location
    Kolkata
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Vlookup help

    @Haseeb A: can u elaborate the formula a bit more so that I can understand this thing. Just wanna learn new things and dont only want to get a readymade solution. :D

  9. #9
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: Vlookup help

    Hi again Brajesh. Try the formula auditor in excel...it really helps to see what's going on with each of the components. Here's my interpretation of what's going on from the inner most to outer:

    Substitutes "-" values in A2 of active sheet with each item in the array {"","-","/"," "}. If A2 contains TKO-147 the result would be TKO147,TKO-147,TKO/147,TKO 147.
    Please Login or Register  to view this content.
    Match below returns the row number where the values in the curly brackets (results of above) are found. Asterisks are used as wild cards so the array item can be found in any position of the searched text. Lets say that TKO/147 is found in row 3, then the results below would be {#N/A,3,#N/A,#N/A}
    Please Login or Register  to view this content.
    Lookup...a very useful and under-utilized function, has two ways to be used. In this case it's looking up a value in the array created by the match function above {#N/A,3,#N/A,#N/A} and returns the first result less than 2^20, which is the number of rows in Excel 2007 & 2010 (1,048,576 rows).
    Please Login or Register  to view this content.
    Index then looks at the result of LOOKUP, which is 3 and returns the value of the specified row of the range specified (Sheet2!B:B)
    Please Login or Register  to view this content.
    Then of course, if there were an error the function below would return "N/A".
    Please Login or Register  to view this content.
    Hope that helps...and hope you don't mind my explanation Haseeb! Thanks!

  10. #10
    Registered User
    Join Date
    02-28-2012
    Location
    Kolkata
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Vlookup help

    Quote Originally Posted by gjlindn View Post
    Hi again Brajesh. Try the formula auditor in excel...it really helps to see what's going on with each of the components. Here's my interpretation of what's going on from the inner most to outer:

    Substitutes "-" values in A2 of active sheet with each item in the array {"","-","/"," "}. If A2 contains TKO-147 the result would be TKO147,TKO-147,TKO/147,TKO 147.
    Please Login or Register  to view this content.
    Match below returns the row number where the values in the curly brackets (results of above) are found. Asterisks are used as wild cards so the array item can be found in any position of the searched text. Lets say that TKO/147 is found in row 3, then the results below would be {#N/A,3,#N/A,#N/A}
    Please Login or Register  to view this content.
    Lookup...a very useful and under-utilized function, has two ways to be used. In this case it's looking up a value in the array created by the match function above {#N/A,3,#N/A,#N/A} and returns the first result less than 2^20, which is the number of rows in Excel 2007 & 2010 (1,048,576 rows).
    Please Login or Register  to view this content.
    Index then looks at the result of LOOKUP, which is 3 and returns the value of the specified row of the range specified (Sheet2!B:B)
    Please Login or Register  to view this content.
    Then of course, if there were an error the function below would return "N/A".
    Please Login or Register  to view this content.
    Hope that helps...and hope you don't mind my explanation Haseeb! Thanks!
    wow, that's amazing explanation. will help me a lot in learning these functions.

    Thanks a lot.

  11. #11
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Vlookup help

    brajesh, mind you, in its current configuration, this formula will be able to find a match if a single hyphen, slash or space exists, not otherwise.

    for example, you have a value OST-1302 in Sheet1!A5. in Sheett2!A45, there is OST--1302, which will not be picked up; OST-1302 in Sheet2!A906 will be matched, however.

    if all of these variations matter to you, then you are best using VBA code for Regular Expressions; they are the best tool under the circumstances.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

+ 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