Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Value result from Vlookup

Posted on 2013-11-13
10
Medium Priority
?
439 Views
Last Modified: 2013-11-20
Hi Guys, can anyone help me resolve why the Vlookup is failing in the T column in my spreadsheet and I get a #VALUE# result? It uses a lookup on Column B from a concatenation of cells.
DummyRec4.xlsx
0
Comment
Question by:Justincut
  • 5
  • 3
10 Comments
 
LVL 23

Accepted Solution

by:
NBVC earned 2000 total points
ID: 39645682
It is because the contents of the cell B304 is greater than 255 characters, which VLOOKUP, MATCH, SUMIF, COUNTIF don't work with.

You can try perhaps SUMPRODUCT.. but you need to limit the range sizes to min required.

e.g

=SUMPRODUCT(--(Journals!$B$1:$B$1000=B305),Journals!$O$1:$O$1000)
0
 

Author Comment

by:Justincut
ID: 39645746
What about creating my own Vlookup via a Function inserted into myWorksheet? Would that work? What code would I need?
0
 
LVL 23

Expert Comment

by:NBVC
ID: 39645760
Not sure if a UDF would be more efficient... you can try:

=INDEX(Journals!$B$1:$B$1000,MATCH(TRUE,INDEX(Journals!$B$1:$B$1000=B304,0),0))

again limiting rows to min needed, perhaps by creating a Dynamic Named Range.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Justincut
ID: 39645861
I saw this post on google: can you adapt the Function to my spreadsheet?



Hi,

 

You need to write your own VLOOKUP that doesn't have this limitation.

 

ALT+F11 to open VB editor, right click 'ThisWorkbook and insert module and paste the code below in. Close VB editor and back on the worksheet call with the formula

 

=MyVlookup(A1,Sheet5!A1:B100,2)

 

 

Where A1 is the lookup value, Sheet5A1:B100 is the lookup range and 2 is the column you want to return.

 

 

 

Function MyVlookup(Lval As Range, c As Range, oset As Long) As Variant
 Dim cl As Range
 For Each cl In c.Columns(1).Cells
     If UCase(Lval) = UCase(cl) Then
         MyVlookup = cl.Offset(, oset - 1)
         Exit Function
     End If
     Next
 End Function
0
 
LVL 23

Expert Comment

by:NBVC
ID: 39645885
You would paste the Function macro into your VB editor, by holding ALT and hitting F11, then go to Insert|Module, then paste the function in the window.

Close the editor and in the sheet enter formula like:

=MyVlookup(B304,Journals!B:B,1)

again, the range Journals!B:B is a whole column.  You would need to reduce that for efficiency's sake.

if you want to get column C data, then change to:  =MyVlookup(B304,Journals!B:C,2)
0
 

Author Comment

by:Justincut
ID: 39647334
Its not working in Range "S5". Any ideas why?
0
 
LVL 23

Expert Comment

by:NBVC
ID: 39647697
Can you clarify what you mean?  What exact formula are you using and what is expected?
0
 
LVL 81

Expert Comment

by:byundt
ID: 39647956
You might consider the following alternative to your VLOOKUP in cell T304:
=IFERROR(VLOOKUP($B304,Journals!$B:$Q,15,FALSE),IFERROR(LOOKUP(2,1/(LEFT($B304,255)=LEFT(Journals!$B:$B,255)),Journals!P:P),0))

Note that IFERROR requires Excel 2007 or later.

The first IFERROR uses the VLOOKUP formula that was initially in the cell. It will be faster than an array formula if the concatenation is less than 255 characters.

If the VLOOKUP fails, the next IFERROR uses LOOKUP to return the last match for the first 255 characters in B304 matching a value in worksheet Journals column B. If a match is found, then return a value from Journals column P on that same row.

If the LOOKUP also fails, then return 0.
0
 
LVL 23

Expert Comment

by:NBVC
ID: 39656650
.... sorry wrong thread.....

Justincut, please close this thread as appropriate before starting new threads...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question