Your question, your audience. Choose who sees your identity—and your question—with question security.

HI Guys, I have a Vlookup that does not work as there is a 256 limit in Excel.Would the formula work if I did Left(Range, 255) on the cell the vlookup is on? Some of the cells I vlookup are 400 characters and I get a "#VALUE" error message as a result,

If you are doing a concatenation of lookup parameters so you can use VLOOKUP on what would otherwise be a multi-criteria lookup, you can use an array formula instead.

=LOOKUP(2,1/((A$1:A$1000="

Though the formula only shows two criteria, you can put as many criteria in the denominator of the second parameter as you like. Just surround each Boolean expression by parentheses, then multiply them all together.

To help understand the formula, if there is a match, the second parameter will equal 1. If there is no match, the second parameter will return an error value. Since LOOKUP is searching for a number, it will ignore text and error values. It therefore finds the row in which all criteria are satisfied, and returns a value from a different column in that row.

LOOKUP was originally intended for bracket pricing (approximate) lookups. If you read Microsoft's documentation for the function, you may draw the misleading conclusion that the second parameter has to be sorted in ascending order. For the suggested formula, however, 2 is larger than any possible value returned by the second parameter, so the sorting requirement is moot.

Note that LOOKUP will return the last match if more than one exists.

DummyRec6.xlsx

Each of the VLOOKUP calls in the formula of cell AD5 can be rewritten as a LOOKUP formula like:

=LOOKUP(2,1/(('[Murex BS rec breaks - 111113KMH.xlsx]Rec'!A$1:A$

You didn't post workbook Murex BS rec breaks - 111113 KMH.xlsx so I guessed how column B in the Rec worksheet of that workbook is determined.

Given the length of the above formula, you may want to use a UDF instead with formula like:

=LookupAlt('[Murex BS rec breaks - 111113 KMH.xlsx]Rec'!$B$1:$AL$100

You can use LookupAlt just like the VLOOKUP in your AD5 formula. Just correct the column assignments.

Do not use LookupAlt on entire columns! Doing so will give excruciatingly slow recalc times.

```
'Code goes in regular module sheet
Function LookupAlt(LookupTable As Range, ResultColumn As Long, CritCol1 As Long, Crit1, CritCol2 As Long, Crit2, _
CritCol3 As Long, Crit3, CritCol4 As Long, Crit4, CritCol5 As Long, Crit5, CritCol6 As Long, Crit6, _
CritCol7 As Long, Crit7)
Dim rg1 As Range, rg2 As Range, rg3 As Range, rg4 As Range, rg5 As Range, rg6 As Range, rg7 As Range, rgResults As Range
Set rg1 = LookupTable.Columns(CritCol1)
Set rg2 = LookupTable.Columns(CritCol2)
Set rg3 = LookupTable.Columns(CritCol3)
Set rg4 = LookupTable.Columns(CritCol4)
Set rg5 = LookupTable.Columns(CritCol5)
Set rg6 = LookupTable.Columns(CritCol6)
Set rg7 = LookupTable.Columns(CritCol7)
Set rgResults = LookupTable.Columns(ResultColumn)
LookupAlt = Application.Lookup(2, 1 / ((rg1 = Crit1) * (rg2 = Crit2) * (rg3 = Crit3) * (rg4 = Crit4) * (rg5 = Crit5) * (rg6 = Crit6) * (rg7 = Crit7)), rgResults)
End Function
```

DummyRec6.xlsx

Column AD formulas are working despite this failure because the maximum length in column C is 41 characters. So the alternative VLOOKUP formulas are all working.

I broke the formula in cell AD5 up into 5 lines for ease of explanation:

=IF(ISNA(VLOOKUP($B5,'Prev

IF($J5="","NEW",

IF(ISNA(VLOOKUP($C5,'Prev Day'!$C:$AL,AD$1-1,FALSE))

VLOOKUP($C5,'Prev Day'!$C:$AL,AD$1-1,FALSE))

VLOOKUP($B5,'Prev Day'!$B:$AL,AD$1,FALSE))

Line 1 VLOOKUP returns #N/A! error value because column B on worksheet Prev Day hasn't been truncated to 255 characters. Even if there were a match for the first 255 characters, the VLOOKUP on line 1 won't find it.

The line 2 test for J5 being blank fails, so control passes to the IF(ISNA(VLOOKUP... on line 3. This VLOOKUP works because C5 is both short and always found. As a result, the formula returns the value from the VLOOKUP on line 4.

Brad

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

If you copy the Rec worksheet, you will need to point your VLOOKUP formulas to that worksheet. I suggest instead copying the data from the Rec worksheet and pasting it in a "Previous Day" worksheet in the VLOOKUP workbook. In doing so, you won't need to change any of your formulas. They will all be set up to point to the Previous Day worksheet, and don't need to be changed for the new data.