+ Reply to Thread
Results 1 to 4 of 4

Need help with simplifying this statement using IF, OR & LEFT or finding a better way!

  1. #1
    Registered User
    Join Date
    09-18-2013
    Location
    TX
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Need help with simplifying this statement using IF, OR & LEFT or finding a better way!

    This is my first post and I'm hoping that someone can help me out. I've been searching around for a solution and the one I've managed to cobble together just doesn't seem efficient at all and seems to hog resources.

    I have a column of various part numbers with different 3-digit prefixes which designate their type (Finished Good, Sub-Assembly, Raw Material, Supply Item). For example, the prefixes 100, 200 & 300 indicate "Finished Goods", so I would want a formula to look at column A and return "Finished Goods" into Column B for any parts with those prefixes. The same also applies for other prefixes and part types.

    I was able to accomplish this with the following formula, but it's gigantic and would have to be much larger in order to include all of the prefixes that exist (approximately 35 different ones):

    =IF(OR(--LEFT(A7,3)=100,--LEFT(A7,3)=200,--LEFT(A7,3)=300),"Finished Good", IF(OR(--LEFT(A7,3)=150,--LEFT(A7,3)=155,--LEFT(A7,3)=250),"Sub-Assembly", IF(OR(--LEFT(A7,3)=180,--LEFT(A7,3)=280,--LEFT(A7,3)=350),"Raw Material", "Not Found")))

    There has got to be a better and more elegant way to do this, I just haven't been able to figure it out.

    Any help is greatly appreciated!

    Below is an example of the end result I'm looking for.

    Column A Column B
    100-001001 Finished Good
    200-001001 Finished Good
    300-001001 Finished Good
    150-001001 Sub Assembly
    155-001001 Sub-Assembly
    250-001001 Sub-Assembly
    180-001001 Raw Material
    280-001001 Raw Material
    350-001001 Raw Material
    700-001001 Supply Item
    710-001001 Supply Item
    730-001001 Supply Item

  2. #2
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Need help with simplifying this statement using IF, OR & LEFT or finding a better way!

    =IF(OR(--LEFT(A7,3)={100,200,300}),"Finished Good", IF(OR(--LEFT(A7,3)={150,155,250}),"Sub-Assembly", IF(OR(--LEFT(A7,3)={180,280,350}),"Raw Material", "Not Found")))

    Or probably VLOOKUP woudl be better.
    make a table within your workbook and use
    =VLOOKUP(--LEFT(A2,3),$K$2:$L$50,2,0)

    Where $K$2:$L$50 is the table to look at.
    Last edited by RobertMika; 09-18-2013 at 06:03 PM.
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  3. #3
    Registered User
    Join Date
    09-18-2013
    Location
    TX
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Need help with simplifying this statement using IF, OR & LEFT or finding a better way!

    Quote Originally Posted by RobertMika View Post
    =IF(OR(--LEFT(A7,3)={100,200,300}),"Finished Good", IF(OR(--LEFT(A7,3)={150,155,250}),"Sub-Assembly", IF(OR(--LEFT(A7,3)={180,280,350}),"Raw Material", "Not Found")))

    Or probably VLOOKUP woudl be better.
    make a table within your workbook and use
    =VLOOKUP(--LEFT(A2,3),$K$2:$L$50,2,0)

    Where $K$2:$L$50 is the table to look at.
    Thanks for the tips. I wanted to avoid adding additional tabs to the workbook and doing vlooks, so your code works just fine. I had tried something similar but I guess I wasn't getting the formatting right. Thanks a bunch!

  4. #4
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Need help with simplifying this statement using IF, OR & LEFT or finding a better way!

    You are welcome.
    If you happy with solution please add reputation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Can anyone help with simplifying this super long Excel IF statement?
    By YPerez in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-21-2013, 05:35 PM
  2. Finding Keywords and Simplifying
    By Miri_tx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2011, 06:04 PM
  3. Simplifying Conditions for If Statement
    By Airgaf in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-25-2011, 09:21 PM
  4. Replies: 10
    Last Post: 12-17-2009, 02:00 AM
  5. Simplifying a Conditional Formatting Statement
    By ChemistB in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-03-2007, 03:43 PM

Tags for this Thread

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.6.0 RC 1