+ Reply to Thread
Results 1 to 9 of 9

Too many Nested IF Statements... Alternative?

  1. #1
    Registered User
    Join Date
    08-11-2016
    Location
    Washington, D.C.
    MS-Off Ver
    Office 2016
    Posts
    3

    Too many Nested IF Statements... Alternative?

    Hi Everyone,


    I have 7 different products with their own item code. I am currently using nested If statements to automatically put in the appropriate code based on the name of the product. If the function finds "product name", it will output "product code".

    The problem is that it becomes a little hard to keep track of the if statements, and I feel that Excel must have a more efficient way to do this... I tried Index Match so that it would look up the products from an array, but that is not working for me, because "product name" is different from "product code", but Index Match only returns "product name".

    The list of products I currently have is only 2... I haven't even entered the rest because it was getting so long...

    - CRM Anywhere
    - CRM Anywhere Pro

    Here is the process I am trying to achieve... I download a report... the report shows the product names as shown above... I want excel to look for the keyword "Anywhere", and then if that's true, determine if it's just Anywhere, or if it's Anywhere Pro. Then, once it determines which one it is from a string of text that varies, I want it to output the appropriate product code.

    Below is the code that I am entering for JUST these two products... I still need to enter more products:

    =IF(LEN(Source_Data!E4)>0,IF(ISNUMBER(SEARCH("Anywhere",Source_Data!E4)),IF(ISNUMBER(SEARCH("Pro",Source_Data!E4)),"CRM ANYWHERE PRO","CRM ANYWHERE"),""),"")

    Any help would be greatly appreciated!

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Too many Nested IF Statements... Alternative?

    probably just a vlookup against a table would work better. a small sample might go a long way to get better help.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,319

    Re: Too many Nested IF Statements... Alternative?

    Post a sample file (not image) showing examples of expected outcomes.

    To post a file, click "Go Advanced" then scroll down to "Manage Attachments"

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,565

    Re: Too many Nested IF Statements... Alternative?

    Normally, you would use VLOOKUP or INDEX/MATCH if you are looking up a value. However, if it is a sub-string of a larger string of alph-numeric text, you might need something else.

    I suggest you post a sample workbook with some typical data and your expected outcome.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    08-11-2016
    Location
    Washington, D.C.
    MS-Off Ver
    Office 2016
    Posts
    3

    Re: Too many Nested IF Statements... Alternative?

    I think I attached the workbook... please let me know if you do not see it, and thanks again!
    Attached Files Attached Files

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Too many Nested IF Statements... Alternative?

    right offhand this would seem shorter (easier) and you can add the others in the list you have to get it to the 7 values you have...
    =IF(OR(Source_Data!E2="crm - anywhere pro",Source_Data!E2="crm - anywhere"),Source_Data!E2,"")

  7. #7
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Too many Nested IF Statements... Alternative?

    this would be another option. Somewhere in another area set up a defined table with your 7 options you want as items (in this formula I set it up in the csv import sheet in cells i17 and i18 but you can put them anywhere). Then use this formula in (I'm assuming in column H of the csv import tab) =IF(IFERROR(VLOOKUP(Source_Data!E2,'CSV Import'!$I$17:$I$18,1,FALSE),"")="","",VLOOKUP(Source_Data!E2,'CSV Import'!$I$17:$I$18,1,FALSE)) and copy down.

  8. #8
    Registered User
    Join Date
    08-11-2016
    Location
    Washington, D.C.
    MS-Off Ver
    Office 2016
    Posts
    3

    Re: Too many Nested IF Statements... Alternative?

    Thanks for the replies! I guess I'm going with the VLOOKUP, or Index(Match()) functions. It turns out this is working way better than using endless IF Statements lol.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,565

    Re: Too many Nested IF Statements... Alternative?

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. [SOLVED] Alternative to nested IF statements
    By zachdking in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-18-2015, 11:45 PM
  2. Alternative to Nested If Statements
    By Kashus in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-10-2015, 07:23 PM
  3. Alternative to multiple nested IF statements to SUM certain values
    By JTR616 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-24-2013, 06:23 PM
  4. [SOLVED] Need an alternative to lots of nested IF statements
    By BeachRock in forum Excel General
    Replies: 8
    Last Post: 03-24-2012, 12:44 AM
  5. Alternative to using multiple nested IF statements
    By maacmaac in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-15-2011, 12:51 PM
  6. Alternative to multiple nested if statements
    By booo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-20-2010, 05:53 PM
  7. alternative to too many nested IF statements
    By lintcoop in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-06-2009, 04:23 PM

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