• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Vlookup: carriage return in Lookup value and output?

Zexall

New Member
Hi All - Hoping a ninja can help with a means to make this work.

I have a sheet where sometimes the values are a one to one match, and sometimes there are multiple inputs that require multiple matches (2 at most). Those with multiple, are separated with a carriage return, and ideally I'd like the output to have a corresponding carriage return. I've attached a small example with a expected output. Any ideas would be greatly appreciated.

Thanks much!
 

Attachments

  • Chandoo sample.xlsx
    9.9 KB · Views: 17
Using Power Query, I reorganized your Lookup Field. Here is the Mcode and what the result looks like. With data like this, you can now do a Vlookup

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    SplitColumnWithLineFeed = Table.SplitColumn(Source, "Look_up", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Look_up.1", "Look_up.2"}),
    UnpivotColumns = Table.UnpivotOtherColumns(SplitColumnWithLineFeed, {}, "Attribute", "Value"),
    RemoveColumnNotNeeded = Table.RemoveColumns(UnpivotColumns,{"Attribute"})
in
    RemoveColumnNotNeeded

vA
1Value
23500074170
33500074150
43610049180
53500077012
63610020225
73500077012
 

Attachments

  • Chandoo sample.xlsx
    18.7 KB · Views: 7
Unfortunately that wouldn't work - I need to keep them grouped together in the end. I thought about using power query to split it into columns (so I knew what exactly was grouped together at the start), do searches, then concat it back, but I'd prefer to not do that if I don't have to.
 
Beginner level formula to enter in cell B2 :​
=IF(ISERR(SEARCH(CHAR(10),A2)),VLOOKUP(A2,D:E,2,FALSE),VLOOKUP(LEFT(A2,SEARCH(CHAR(10),A2)-1)*1,D:E,2,FALSE)&CHAR(10)&VLOOKUP(MID(A2,SEARCH(CHAR(10),A2)+1,LEN(A2)-SEARCH(CHAR(10),A2))*1,D:E,2,FALSE))
The Wrap Text check box must be checked within the cell formatting Alignment tab (first check box of Text control section) …​
Do you like it ? So thanks to click on bottom right Like !​
 
I need to keep them grouped together in the end.
But in your file which showed your expected solution, it looks exactly like I have presented. I don't understand why you cannot use this as a step to your final solution. You have confused me greatly.
 
In the Column A criteria range, cell A4 and A5 have multiple value and with duplicate value (3500077012)

VLOOKUP() unable to return the 2nd match value, and should be replaced with INDEX+AGGREGATE()

Thus,

In B2, formula copied down, and formatted with "Wrap Text" :

=IF(A2="","",IF(ISERR(FIND(CHAR(10),A2)),VLOOKUP(A2,D$2:E$7,2,0),VLOOKUP(0+LEFT(A2,10),D$2:E$7,2,0)&CHAR(10)&INDEX(E$1:E$7,AGGREGATE(15,6,ROW(D$1:D$7)/(D$1:D$7=0+RIGHT(A2,10)),SUMPRODUCT(1-ISERR(FIND(RIGHT(A2,10),A$2:A2)))))))

67193
 
If you have TEXTJOIN function then a simpler formula can be used.

=TEXTJOIN(CHAR(10),TRUE,IF(ISNUMBER(SEARCH($E$2:$E$7,A2,1)),$F$2:$F$7,""))
 
Back
Top