+ Reply to Thread
Results 1 to 8 of 8

combination of IF, INDEX/MATCH command

  1. #1
    Registered User
    Join Date
    11-19-2010
    Location
    MN
    MS-Off Ver
    Excel 2003
    Posts
    2

    combination of IF, INDEX/MATCH command

    The code below is not working for me and I don't know why.

    =IF(E30=2.7,INDEX(AA10:AA14,MATCH(E32,X10:X14,0)),IF(E30=3,INDEX(AA15:AA19,MATCH(E32,X15:X19,0)),IF(E30=3.3,INDEX(AA20:AA24,MATCH(E32,'X20:X24,0)),IF(E30=3.5,INDEX(AA25:AA29,MATCH(E32,X25:X29,0)),IF(E30=3.7,INDEX(AA30:AA34,MATCH(E32,X30:X34,0)),IF(E30=4,INDEX(AA35:AA39,MATCH(E32,X35:X39,0)),IF(E30=4.2,INDEX(AA340:AA44,MATCH(E32,X40:X44,0)),IF(E30=4.5,INDEX(AA45:AA49,MATCH(E32,X45:X349,0)),""))))))))

    If I shorten it to the following i(take out the last to INDEX/MATCH commands) it works fine:

    =IF(E30=2.7,INDEX(AA10:AA14,MATCH(E32,X10:X14,0)),IF(E30=3,INDEX(AA15:AA19,MATCH(E32,X15:X19,0)),IF(E30=3.3,INDEX(AA20:AA24,MATCH(E32,'X20:X24,0)),IF(E30=3.5,INDEX(AA25:AA29,MATCH(E32,X25:X29,0)),IF(E30=3.7,INDEX(AA30:AA34,MATCH(E32,X30:X34,0)),IF(E30=4,INDEX(AA35:AA39,MATCH(E32,X35:X39,0)),IF(E30=4.2,4.2,IF(E30=4.5,4.5,""))))))))

    but I'd like to be able to call up values for "4.2" and "4.5" as well. Anybody have any suggestions? Thanks for the help.
    Last edited by NBVC; 11-23-2010 at 12:44 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    re: combination of IF, INDEX/MATCH command

    You can only nest 7 levels deep in Excel 2003.

    You could change it to something like,

    =CHOOSE(MATCH(E30, {2.7,3,3,3,3.7,3.7,4,4.2}, 0),
    INDEX(AA10:AA14, MATCH(E32, X10:X14, 0)),
    INDEX(AA15:AA19, MATCH(E32, X15:X19, 0)),
    ...
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    re: combination of IF, INDEX/MATCH command

    If you setup a table of values where you list the possible E30 values, and in next 2 columns, the corresponding AA range and X range,

    e.g. in I1: 2.7, in J1: AX10:AX14, in K1:X10:X14 and continue in I2:K2, etc...

    then you can use:

    Please Login or Register  to view this content.
    where I1:K10 contains the table of values.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    08-30-2010
    Location
    Mpls, MN
    MS-Off Ver
    Excel 2003
    Posts
    17

    re: combination of IF, INDEX/MATCH command

    I found neither work as there is a stray apostrophe at E32,'X20:X24 just after E30=3.3

  5. #5
    Valued Forum Contributor
    Join Date
    02-08-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    122

    re: combination of IF, INDEX/MATCH command

    One more,

    =INDEX(OFFSET($AA$1,5*MATCH(E30,{0,2.7,3,3,3,3.7,3.7,4,4.2}, 0)-1,0,5,1),MATCH(E32,OFFSET($X$1,5*MATCH(E30,{0,2.7,3,3,3,3.7,3.7,4,4.2}, 0)-1,0,5,1),0))

    Or you can use an auxiliary cell, les't say E31.
    =5*MATCH(E30,{0,2.7,3,3,3,3.7,3.7,4,4.2}, 0)-1

    Then
    =INDEX(OFFSET($AA$1,E31,0,5,1),MATCH(E32,OFFSET($X$1,E31,0,5,1),0))

    Reagrds

  6. #6
    Registered User
    Join Date
    08-30-2010
    Location
    Mpls, MN
    MS-Off Ver
    Excel 2003
    Posts
    17

    re: combination of IF, INDEX/MATCH command

    Check out this substitute formula example as an alternative to your long IF statement. You can use the Indirect function to create cell address's on the fly, or from a table in this case. If you only have the single formula then debug what you have. (The error is likely a comma misplacement or paren misplacement. If you have lots of this formula, use the version I provided to speed the calculations and reduce memory requirements.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    02-08-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    122

    re: combination of IF, INDEX/MATCH command

    One more no volatile

    E31=5*MATCH(E30,{0,2.7,3,3.3,3.5,3.7,3.7,4,4.2},0)

    Then
    =INDEX(INDEX(AA:AA,E31):INDEX(AA:AA,E31+4),MATCH(E32,INDEX(X:X,E31):INDEX(X:X,E31+4),0))


    Or if the ranges could be in different columns or rows than multiple of 5.

    E31=MATCH(E30,{2.7,3,3.3,3.5,3.7,3.7,4,4.2},0)


    Then
    =INDEX(INDEX((AA10:AA14,AA15:AA19,AA20:AA24,AA25:AA29,AA30:AA34,AA35:AA39,AA40:AA44,AA45:AA49),0,0,E31),MATCH(E32,INDEX((X10:X14,X15:X19,X20:X24,X25:X29,X30:X34,X35:X39,X40:X44,X45:X49),0,0,E31),0))


    Regards
    Last edited by sailepaty; 11-19-2010 at 02:18 PM.

  8. #8
    Registered User
    Join Date
    11-19-2010
    Location
    MN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: combination of IF, INDEX/MATCH command

    Quote Originally Posted by shg View Post
    You can only nest 7 levels deep in Excel 2003.

    You could change it to something like,

    =CHOOSE(MATCH(E30, {2.7,3,3,3,3.7,3.7,4,4.2}, 0),
    INDEX(AA10:AA14, MATCH(E32, X10:X14, 0)),
    INDEX(AA15:AA19, MATCH(E32, X15:X19, 0)),
    ...
    Thanks. This worked. I appreciate the help.

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