VLOOKUP on partial text in a string

raheem

New Member
Joined
Apr 24, 2017
Messages
38
I want to detect a part of string from a cell and then apply vlookup to get corresponding value from another table. Please refer below tables. Values are to be extracted from second table into first table: (there are also few spaces in first table in start of string)

First Table
[TABLE="class: grid, width: 500"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Structure[/TD]
[TD="align: center"]Value[/TD]
[/TR]
[TR]
[TD]** WBS 99OP-11223.P.01 Project RT[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]* WBS 99OP-11223.P.01.01 Project Roots Data[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] WBS 99OP-11223.P.01.01.01 First Line Item[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] WBS 99OP-11223.P.01.01.02 Second Line Products[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] WBS 99OP-11223.P.01.01.03 Third Line Items[/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]

Second Table
[TABLE="class: grid, width: 476"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Structure[/TD]
[TD="align: center"]Value[/TD]
[/TR]
[TR]
[TD]99OP-11223.P.01[/TD]
[TD="align: right"]25,254,759[/TD]
[/TR]
[TR]
[TD]99OP-11223.P.01.01[/TD]
[TD="align: right"]25,254,759[/TD]
[/TR]
[TR]
[TD]99OP-11223.P.01.01.01[/TD]
[TD="align: right"]1,910,442[/TD]
[/TR]
[TR]
[TD]99OP-11223.P.01.01.02[/TD]
[TD="align: right"]7,176,356[/TD]
[/TR]
[TR]
[TD]99OP-11223.P.01.01.03[/TD]
[TD="align: right"]3,796,289[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi. See if this works for you:

=INDEX($B$9:$B$13,MATCH(TRUE,INDEX(ISNUMBER(SEARCH(" "&$A$9:$A$13&" "," "&A2&" ")),0),0))

Table 1 in A1:B6. Table 2 in A8:B13
 
Upvote 0
something like...

B3=LOOKUP(2^15,SEARCH($A$11:$A$15,A3),$B$11:$B$15)

[TABLE="class: grid"]
<tbody>[TR]
[TD]Row\Col[/TD]
[TD]
A​
[/TD]
[TD]
B​
[/TD]
[/TR]
[TR]
[TD]
1​
[/TD]
[TD]First Table[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
2​
[/TD]
[TD]Structure[/TD]
[TD]
Value​
[/TD]
[/TR]
[TR]
[TD]
3​
[/TD]
[TD]** WBS 99OP-11223.P.01 Project RT[/TD]
[TD]
25254759​
[/TD]
[/TR]
[TR]
[TD]
4​
[/TD]
[TD]* WBS 99OP-11223.P.01.01 Project Roots Data[/TD]
[TD]
25254759​
[/TD]
[/TR]
[TR]
[TD]
5​
[/TD]
[TD]WBS 99OP-11223.P.01.01.01 First Line Item[/TD]
[TD]
1910442​
[/TD]
[/TR]
[TR]
[TD]
6​
[/TD]
[TD]WBS 99OP-11223.P.01.01.02 Second Line Products[/TD]
[TD]
7176356​
[/TD]
[/TR]
[TR]
[TD]
7​
[/TD]
[TD]WBS 99OP-11223.P.01.01.03 Third Line Items[/TD]
[TD]
3796289​
[/TD]
[/TR]
[TR]
[TD]
8​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
9​
[/TD]
[TD]Second Table[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
10​
[/TD]
[TD]Structure[/TD]
[TD]
Value​
[/TD]
[/TR]
[TR]
[TD]
11​
[/TD]
[TD]99OP-11223.P.01[/TD]
[TD]
25,254,759​
[/TD]
[/TR]
[TR]
[TD]
12​
[/TD]
[TD]99OP-11223.P.01.01[/TD]
[TD]
25,254,759​
[/TD]
[/TR]
[TR]
[TD]
13​
[/TD]
[TD]99OP-11223.P.01.01.01[/TD]
[TD]
1,910,442​
[/TD]
[/TR]
[TR]
[TD]
14​
[/TD]
[TD]99OP-11223.P.01.01.02[/TD]
[TD]
7,176,356​
[/TD]
[/TR]
[TR]
[TD]
15​
[/TD]
[TD]99OP-11223.P.01.01.03[/TD]
[TD]
3,796,289​
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Unknown
AB
1StructureValue
2** WBS 99OP-11223.P.01 Project RT25254759
3* WBS 99OP-11223.P.01.01 Project Roots Data25254759
4WBS 99OP-11223.P.01.01.01 First Line Item1910442
5WBS 99OP-11223.P.01.01.02 Second Line Products7176356
6WBS 99OP-11223.P.01.01.03 Third Line Items3796289
7
8
9StructureValue
1099OP-11223.P.012,52,54,759
1199OP-11223.P.01.012,52,54,759
1299OP-11223.P.01.01.0119,10,442
1399OP-11223.P.01.01.0271,76,356
1499OP-11223.P.01.01.0337,96,289
15
12 bom page
Cell Formulas
RangeFormula
B2=INDEX($B$10:$B$14,AGGREGATE(14,6,ISNUMBER(SEARCH($A$10:$A$14,A2))*(ROW($A$10:$A$14)-ROW($A$10)+1),1))
 
Upvote 0
This worked great as desired with a little modification. Search should be SEARCH(" "&$A$11:$A$15&" "," "&A3&" "). Otherwise it will search also the value with shorter if exact string is not found.

Thanks for the tip.
 
Upvote 0
something like...

B3=LOOKUP(2^15,SEARCH($A$11:$A$15,A3),$B$11:$B$15)

[TABLE="class: grid"]
<tbody>[TR]
[TD]Row\Col[/TD]
[TD]
A​
[/TD]
[TD]
B​
[/TD]
[/TR]
[TR]
[TD]
1​
[/TD]
[TD]First Table[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
2​
[/TD]
[TD]Structure[/TD]
[TD]
Value​
[/TD]
[/TR]
[TR]
[TD]
3​
[/TD]
[TD]** WBS 99OP-11223.P.01 Project RT[/TD]
[TD]
25254759​
[/TD]
[/TR]
[TR]
[TD]
4​
[/TD]
[TD]* WBS 99OP-11223.P.01.01 Project Roots Data[/TD]
[TD]
25254759​
[/TD]
[/TR]
[TR]
[TD]
5​
[/TD]
[TD]WBS 99OP-11223.P.01.01.01 First Line Item[/TD]
[TD]
1910442​
[/TD]
[/TR]
[TR]
[TD]
6​
[/TD]
[TD]WBS 99OP-11223.P.01.01.02 Second Line Products[/TD]
[TD]
7176356​
[/TD]
[/TR]
[TR]
[TD]
7​
[/TD]
[TD]WBS 99OP-11223.P.01.01.03 Third Line Items[/TD]
[TD]
3796289​
[/TD]
[/TR]
[TR]
[TD]
8​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
9​
[/TD]
[TD]Second Table[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
10​
[/TD]
[TD]Structure[/TD]
[TD]
Value​
[/TD]
[/TR]
[TR]
[TD]
11​
[/TD]
[TD]99OP-11223.P.01[/TD]
[TD]
25,254,759​
[/TD]
[/TR]
[TR]
[TD]
12​
[/TD]
[TD]99OP-11223.P.01.01[/TD]
[TD]
25,254,759​
[/TD]
[/TR]
[TR]
[TD]
13​
[/TD]
[TD]99OP-11223.P.01.01.01[/TD]
[TD]
1,910,442​
[/TD]
[/TR]
[TR]
[TD]
14​
[/TD]
[TD]99OP-11223.P.01.01.02[/TD]
[TD]
7,176,356​
[/TD]
[/TR]
[TR]
[TD]
15​
[/TD]
[TD]99OP-11223.P.01.01.03[/TD]
[TD]
3,796,289​
[/TD]
[/TR]
</tbody>[/TABLE]

This worked great as desired with a little modification. Search should be SEARCH(" "&$A$11:$A$15&" "," "&A3&" "). Otherwise it will search also the value with shorter if exact string is not found.

Thanks for the tip.

 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top