Solved

Excel: Data validation to search for particular string

Posted on 2012-03-14
13
381 Views
Last Modified: 2012-03-14
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.

thanks
capt.
0
Comment
Question by:captain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 33

Assisted Solution

by:Rob Henson
Rob Henson earned 150 total points
ID: 37719575
Assuming value in A1, this will strip out the middle 4 characters:

=MID(A1,7,4)

Contained in your lookup would be:

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

Thanks
Rob H
0
 
LVL 13

Assisted Solution

by:Philip Pinnell
Philip Pinnell earned 350 total points
ID: 37719601
excel
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
0
 
LVL 30

Author Comment

by:captain
ID: 37719697
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...
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 37719727
Match returns a relative position whereas lookup returns a value
0
 
LVL 30

Author Comment

by:captain
ID: 37719825
OK.

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

=VLOOKUP(MID(A2,7,4),Consolidator!$A$2:$B$32,2)

Open in new window


However, it does not return the correct value...baffled
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 37719851
What does it return? It looks ok from here but obviously I can't see your table
0
 
LVL 30

Author Comment

by:captain
ID: 37719872
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..
0
 
LVL 13

Accepted Solution

by:
Philip Pinnell earned 350 total points
ID: 37719913
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)
0
 
LVL 30

Author Comment

by:captain
ID: 37719947
Here is a file with some of the products, to show the issue.

Test.xlsx

I will sort this in the meantime...

EDIT: Sorting worked...now onto the big file...
0
 
LVL 30

Author Comment

by:captain
ID: 37719976
Worked!
0
 
LVL 30

Author Closing Comment

by:captain
ID: 37719982
Thanks all, split for getting me there.
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 37719987
Sorting fixes it. Using the last parameter has limited results by itself. Not sure why
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 37719998
Thanks
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question