To best describe the issue:
I have a pdf of a bunch of text, only a portion is useful to me. The info I want to extract is a UPC code. Sometimes, the UPC code is 11 digits, sometimes it is 12.
I understand how to use the MID function, but It doesn't always work. There are two reasons that this does not work:
1. Sometimes, the UPC code is 11 digits, while others it is 12 digits.
2. Sometimes, there are 3 characters before the desired UPC, and sometimes there are 4.
Is there a way to have Excel recognize when to have the MID formula start counting after 3 characters or four? Is there a way t have Excel know when my UPC is 11 digits or 12, and produce only the UPC?
Can I combine the necessary formulas in one cell, and have it display only my desired UPC?
Last edited by larstrak; 07-07-2011 at 01:58 PM. Reason: Added demo worksheet
Is the UPC first set of numbers between the first and second space?
If so, try:
=TRIM(MID(A1,FIND(" ",A1)+1,FIND("^^",SUBSTITUTE(A1," ","^^",2))-FIND(" ",A1)))
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Thank you for your response. Your time and effort is appreciated.
Yes, the UPC is between the first and second spaces.
Your proposed solution does not work for me, unless I have plugged it in incorrectly. I have copied and pasted your formula and only the last 3 characters of my desired UPC are produced.
See attached
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Thank you very much for your quick solution.
The reason it wasn't working for me is that I did not uncheck "Wrap Text".
I don't fully understand the formula that you have provided, but it works flawlessly for me. I will work on dissecting this piece by piece on my own to fully understand what you have provided.
Thank you so kindly for your help.
Use the Evaluate tool found in Tools|Formula Auditing menu.. you will see the steps as you click Evaluate...
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
I think you're made of magic. Thanks again!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks