Lookup on partial text value

Snuffepuff

New Member
Joined
Aug 27, 2014
Messages
9
Hi,

I'm trying to get my spread sheet to return a value based on only a part of a the provided text.

In cell A1 I got the full name of a product, ABC-123. ABC is the model name, which costs a specific amount that I want to extract with a Lookup.

ProductCost?SeriesCost
ABC-123ABC100

<tbody>
</tbody>

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>

I've been trying to sort this with MATCH unsecsessfully. Any options?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

anglais428

Well-known Member
Joined
Nov 23, 2009
Messages
634
Office Version
  1. 2016
Platform
  1. Windows
=VLOOKUP(LEFT(A2,3),$C$2:$D$2,2,0)

If you are going to have products with different string lengths then you need to change the lookup to something like (assuming the dash will be a unique separator:
=VLOOKUP(LEFT(A2,FIND("-",A2)-1),$C$2:$D$2,2,0)
 
Upvote 0

Snuffepuff

New Member
Joined
Aug 27, 2014
Messages
9
Thanks!

I see now that I made a misstake putting the dash in as a separator. The product name is ABC123, not ABC-123 so there's no separator at all. The main issue I got is that all the product are not the same length. Same might be named ABC12345 and others ABC12. Also the difference so sometimes it might be AB, othertimes it's ABCD.

It's because of this I can't find any simple solution.
 
Upvote 0

anglais428

Well-known Member
Joined
Nov 23, 2009
Messages
634
Office Version
  1. 2016
Platform
  1. Windows
If the combination is always text followed by numbers then you can separate these into two separate (helper) columns.
E.g. in Cell A2 say we have ABC123
In B2 enter =Left(A2,min(Find({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))-1)
The above should give ABC
In C2 enter =Right(A2,len(A2)-min(find({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))+1)
The above should give 123

The just perform a standard Vlookup on cell B2. (Adjust your ranges as necessary).
 
Upvote 0

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,945
Office Version
  1. 365
Platform
  1. Windows
Hi, does this help at all?

Excel Workbook
ABCDE
1ProductCost?SeriesCost
2ABC-123100ABC100
3GHI123456710DEF50
4DEF99950GHI10
5JLK5
Sheet1
 
Upvote 0

Snuffepuff

New Member
Joined
Aug 27, 2014
Messages
9
Hi, does this help at all?

Sheet1

*ABCDE
1ProductCost?*SeriesCost
2ABC-123100*ABC100
3GHI123456710*DEF50
4DEF99950*GHI10
5***JLK5

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:93px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
B2=LOOKUP(1,1/COUNTIF(A2,$D$2:$D$5&"*"),$E$2:$E$5)

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

This worked out when I put in extra cells (like A in the example). Many thanks!
 
Upvote 0

Forum statistics

Threads
1,195,670
Messages
6,011,074
Members
441,580
Latest member
BornholmerBjarne

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
Top