+ Reply to Thread
Results 1 to 11 of 11

Using large amounts of IF statements

  1. #1
    Registered User
    Join Date
    04-05-2015
    Location
    Malta
    MS-Off Ver
    2013
    Posts
    4

    Using large amounts of IF statements

    I'm using concatenated If statements, in this format: =IF(B5="A",I32,"")&IF(B5="B",I39,"")&IF(B5="C",I45,""). However, there's a limit of 30 or so, and I'd like to use more than that, over 100. Is there any way to get around this, maybe by using another formula? Thanks.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using large amounts of IF statements

    Create a 2 column table and use a lookup formula.

    See this:

    http://contextures.com/xlFunctions02.html
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Using large amounts of IF statements

    Hi, welcome to the forum

    I suggest you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.

    edit: Tony, there are a bunch of &'s in there, so it will need more than just a lookup table (I think?)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    04-05-2015
    Location
    Malta
    MS-Off Ver
    2013
    Posts
    4

    Re: Using large amounts of IF statements

    Thanks for the answers. I'll take a look at the link.

    What I have are a list of football teams and the amount of goals they score, so like (Arsenal, 1.9), (Aston Villa, 0.8), and so on. What I want is to be able to input the name of the team in one cell (B90), and have the number of goals displayed for that team in another cell. So, the formula goes like this: =IF(B90="Arsenal",H117,"")&IF(B90="Aston Villa",H124,"")&IF(B90="Burnley",H130,""), but after a certain amount of If statements, I can't add any more.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Using large amounts of IF statements

    If you have the number of goals for Arsenal in H117 and number of goals for Aston Villa in H124 etc. then presumably the club names are also in column H? Is Arsenal in H116 or H115 or in an adjacent column? If that's the case you can probably use an INDEX/MATCH formula to pull the relevant goals number depending on the team, e.g. if the team name is always 2 cells above the goals figure then you could use this formula

    =INDEX(H$117:H$1002,MATCH(B90,H$115:H$1000,0))

    Note that the first range is "offset" by 2 from the second range
    Audere est facere

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Using large amounts of IF statements

    Maybe Tony was correct after all....
    A
    B
    1
    Team
    2
    aa
    1.9
    3
    bb
    0.8
    4
    cc
    2.1
    5
    6
    bb
    7
    0.8

    A7=VLOOKUP(A6,$A$2:$B$4,2,0)

  7. #7
    Registered User
    Join Date
    04-05-2015
    Location
    Malta
    MS-Off Ver
    2013
    Posts
    4

    Re: Using large amounts of IF statements

    Thanks for your answer. The team names are in a different column (column A) in the same row, e.g. Arsenal is at A117 and their goals are at H117.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Using large amounts of IF statements

    adjust the ranges as needed
    =VLOOKUP(A6,$A$2:$H$500,8,0)

  9. #9
    Registered User
    Join Date
    04-05-2015
    Location
    Malta
    MS-Off Ver
    2013
    Posts
    4

    Re: Using large amounts of IF statements

    Yes, thanks FDibbins, that makes everything much simpler! I was tediously writing out 20 or 30 IF statements before thanks to my lack of knowledge.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using large amounts of IF statements

    Quote Originally Posted by FDibbins View Post
    Maybe Tony was correct after all....
    Of course he was!

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Using large amounts of IF statements

    Quote Originally Posted by Tony Valko View Post
    Of course he was!
    Whatever was I thinking? :p

+ 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. Large amounts of data
    By namluke in forum Excel General
    Replies: 3
    Last Post: 12-11-2014, 02:40 PM
  2. Grouping large amounts of data
    By LLForm in forum Excel General
    Replies: 2
    Last Post: 10-28-2014, 11:25 AM
  3. [SOLVED] Rearranging large amounts of data
    By kozor in forum Excel General
    Replies: 6
    Last Post: 10-30-2012, 05:41 AM
  4. Large Amounts of Data
    By Drewser33 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 06-17-2008, 09:13 AM
  5. Doing Analysis from large amounts of DATA
    By william4444 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 05-15-2006, 04:01 AM

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