Results 1 to 10 of 10

20131108, 15:46 #1
 Join Date
 Dec 2006
 Posts
 250
 Thanks
 0
 Thanked 0 Times in 0 Posts
Best way to match a cell value on worksheet
HelloI 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.

20131108, 16:54 #2
 Join Date
 Jan 2001
 Location
 La Jolla, CA
 Posts
 1,360
 Thanks
 22
 Thanked 58 Times in 54 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; 20131108 at 16:59.

20131108, 17:03 #3
 Join Date
 Jul 2002
 Location
 Pittsburgh, Pennsylvania, USA
 Posts
 11,225
 Thanks
 14
 Thanked 342 Times in 335 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))
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; 20131108 at 17:09.

20131108, 17:45 #4
 Join Date
 Jan 2001
 Location
 La Jolla, CA
 Posts
 1,360
 Thanks
 22
 Thanked 58 Times in 54 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?

20131108, 19:05 #5
 Join Date
 Dec 2006
 Posts
 250
 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.

20131109, 04:38 #6
 Join Date
 Jul 2002
 Location
 Pittsburgh, Pennsylvania, USA
 Posts
 11,225
 Thanks
 14
 Thanked 342 Times in 335 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

20131109, 11:52 #7
 Join Date
 Jan 2001
 Location
 La Jolla, CA
 Posts
 1,360
 Thanks
 22
 Thanked 58 Times in 54 Posts
Seba  yes, you need to put the full path in my array formula. I just didn't type it.

20131109, 22:02 #8
 Join Date
 Dec 2006
 Posts
 250
 Thanks
 0
 Thanked 0 Times in 0 Posts
sdckaprYou 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.
KweaverI will try it again and see if that works. Quick questionCan I make the array formula include empty rows. This are needed since I will be providing the formula to staff to copy and paste.

20131110, 05:42 #9
 Join Date
 Jul 2002
 Location
 Pittsburgh, Pennsylvania, USA
 Posts
 11,225
 Thanks
 14
 Thanked 342 Times in 335 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 onebyone 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

20131112, 00:52 #10
 Join Date
 Dec 2006
 Posts
 250
 Thanks
 0
 Thanked 0 Times in 0 Posts
Thanks sdckapr. The formula works.
Last edited by Seba; 20131113 at 00:50.