+ Reply to Thread
Results 1 to 7 of 7

Thread: Combining conditional formulas with MID functions?

  1. #1
    Registered User
    Join Date
    07-07-2011
    Location
    Cincinnati
    MS-Off Ver
    Excel 2003
    Posts
    4

    Question Combining conditional formulas with MID functions?

    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?
    Attached Files Attached Files
    Last edited by larstrak; 07-07-2011 at 01:58 PM. Reason: Added demo worksheet

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Combining conditional formulas with MID functions?

    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.

  3. #3
    Registered User
    Join Date
    07-07-2011
    Location
    Cincinnati
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combining conditional formulas with MID functions?

    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.

  4. #4
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Combining conditional formulas with MID functions?

    See attached
    Attached Files Attached Files
    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.

  5. #5
    Registered User
    Join Date
    07-07-2011
    Location
    Cincinnati
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combining conditional formulas with MID functions?

    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.

  6. #6
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Combining conditional formulas with MID functions?

    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.

  7. #7
    Registered User
    Join Date
    07-07-2011
    Location
    Cincinnati
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combining conditional formulas with MID functions?

    I think you're made of magic. Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0