Excel: Data validation to search for particular string

I have a spreadsheets with 16000 product codes in 31 old product groups, which I need to assign to new product groups.

There are 6 new product groups.

The problem is that the old product groups are not contained as a separate value in a column, but is part of the product code. The code contains redundant elements as prefix and suffix, and the identifier is in the middle of those between two periods.

So for instance:

10000.ABCD.0001 belongs to Product group MEDIA
12333.ADDE.0001 belongs to Product group MEDIA also
12333.BCDA.0001 belongs to Product group PACKAGING

i.e. the first 5 digits, the 2 periods and the last 4 digits are irrelevant for this purpose. Only the 4 letter identifier links to the new product groups.

I have a table with all the 31 identifiers mapped to the new groups.

I now need to compile a formula to check the product codes for the identifier value from the table and return the new product groups for each product code in a new cell.

I know how to do lookups for whole cell values but don't know how to compile the correct syntax for the formula to only match a certain part of the contents to an array.

Any help would be appreciated.

LVL 31
Who is Participating?
George HirstConnect With a Mentor Commented:
I think you should sort your lookup table. My guess is the row 4 is past HUWL in the alphabet and it gives up the lookup at that point.

You perhaps want to include an explicit 'FALSE' as the last parameter of the lookup function (exact match)
Rob HensonConnect With a Mentor Finance AnalystCommented:
Assuming value in A1, this will strip out the middle 4 characters:


Contained in your lookup would be:

=VLOOKUP(MID(A1,7,4),range, offset, lookup_type)

Rob H
George HirstConnect With a Mentor Commented:
A2 is your existing product code

B2 has the formula =VLOOKUP(MID(A2,7,4),D2:E6,2) and gives the translated new prod code based on A2

Column d is old product code
column e is new product coe

D2:E6 represents a table mapping your product code old to new

Hope that makes sense else just ask

Ignore b4
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

captainAuthor Commented:
Makes sense, but I am getting odd results maybe my lookup skill is not as good as it used to be...

Values of old/new product groups is in column A and B of a spreadsheet. Array A2:B32

Do I use MATCH or LOOKUP for this? At the moment it only returns values from A2:B4...
George HirstCommented:
Match returns a relative position whereas lookup returns a value
captainAuthor Commented:

This is my formula, the array for the lookup is on a separate spreadsheets called Consolidator


Open in new window

However, it does not return the correct value...baffled
George HirstCommented:
What does it return? It looks ok from here but obviously I can't see your table
captainAuthor Commented:
The item is .HUWL. which is in row 30 and should return PLK
it returns however the value from row 3 (ASDA) which is SET

so it does not return FALSE just simply the wrong value.

MID(A2,7,4) returns HUWL so the error is in the lookup, I have seen this before where it almost behaves like a bug, and the values would only return correctly if I recreated the file.

I will try that..
captainAuthor Commented:
Here is a file with some of the products, to show the issue.


I will sort this in the meantime...

EDIT: Sorting worked...now onto the big file...
captainAuthor Commented:
captainAuthor Commented:
Thanks all, split for getting me there.
George HirstCommented:
Sorting fixes it. Using the last parameter has limited results by itself. Not sure why
George HirstCommented:
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.