Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    249
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Best way to match a cell value on worksheet

    Hello-I am trying to do a vlookup formula but I an not getting the result I want. The reason I think is that some of the cells in the array table are in text format. I have an error that I can pick that will make this numbers into numbers, however, I can't do this because this won't match the value I am looking up. My formula is this =vlookup(b2,'c:\data\test\Invoice\[log.xls]sheet1'$d1:$G$1500,3). Would a match or an index formula work or is there a way for th lookup to look for values and text too. Any help would be greatly appreciated. Thank you.

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    La Jolla,CA
    Posts
    1,090
    Thanks
    13
    Thanked 37 Times in 36 Posts
    If B2 is a real number and column 1 of your range contains real numbers, with some represented as text, this ARRAY formula should work:

    =INDEX(sheet1!$F1:$F$1500,match(B2,1*sheet1!$D1:$D $1500,0))

    (conform with: ALT+CTRL+Enter)
    Last edited by kweaver; 2013-11-08 at 16:59.

  4. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    Try this:
    Code:
    =IF(ISNUMBER(match(B2,'c:\data\test\Invoice\[log.xls]sheet1'!$D1:$d$1500)),VLOOKUP(B2,'c:\data\test\Invoice\[log.xls]sheet1'!$D1:$G$1500,3),VLOOKUP(B2&"",'c:\data\test\Invoice\[log.xls]sheet1'!$D1:$G$1500,3))
    If it finds a match it does the lookup, if not it tries a text version...
    Steve
    PS this is an approximate match, so the routine expects the series to be sorted and if it is not it can yield odd results...
    The exact match version is:
    Code:
    =IF(ISNUMBER(match(B2,'c:\data\test\Invoice\[log.xls]sheet1'!$D1:$d$1500,0)),VLOOKUP(B2,'c:\data\test\Invoice\[log.xls]sheet1'!$D1:$G$1500,3,0),VLOOKUP(B2&"",'c:\data\test\Invoice\[log.xls]sheet1'!$D1:$G$1500,3,0))
    Last edited by sdckapr; 2013-11-08 at 17:09.

  5. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    La Jolla,CA
    Posts
    1,090
    Thanks
    13
    Thanked 37 Times in 36 Posts
    Steve, you tend not to like array formulas. Why? Are they inefficient? Is it better to do an IF test first and make the decision after that?

  6. #5
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    249
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I couldn't get either formula to work. There is an arrow down within the cell that gives me the options to convert text to number, correct error, ignore error, etc.

    Kweaver: Do you need to specify the file path and worksheet name from where to look at the information in the index formula?

    sdckapr: I get an N/A with the formula you provided.

    Thank you both for your help.

  7. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    kweaver:
    I uise arrays when needed. When not needed, I do not use them. They can be inefficient if there are multiple ones. If you use 1 array for a range of cells, the workbook can be problematic in the future as inserting a deleting rows can become an issue as you can't easily change the array.

    Seba:
    Could you attach an example file, demonstrating the issue. An #NA error for both tests suggests to me that the list is not sorted ...

    Steve

  8. #7
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    La Jolla,CA
    Posts
    1,090
    Thanks
    13
    Thanked 37 Times in 36 Posts
    Seba -- yes, you need to put the full path in my array formula. I just didn't type it.

  9. #8
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    249
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sdckapr-You are right the list is not sorted and unfortunately I can't sort it because we track invoice base on the date they come in and not by invoice number.

    Kweaver-I will try it again and see if that works. Quick question-Can I make the array formula include empty rows. This are needed since I will be providing the formula to staff to copy and paste.

  10. #9
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    If not sorted, the partial match system does not work. The exact match should work however. But if a match is not found you will get an #NA error...
    The exact match starts testing at the start and goes one-by-one through the list. The partial match presumes there is a sort order so can jump around the list and not have to look at all for more efficient lookups.

    Steve

  11. #10
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    249
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks sdckapr. The formula works.
    Last edited by Seba; 2013-11-13 at 00:50.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •