+ Reply to Thread
Results 1 to 8 of 8

Replacing IF /AND formula with VLOOKUP

  1. #1
    Registered User
    Join Date
    02-17-2009
    Location
    LA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Replacing IF /AND formula with VLOOKUP

    Ok so this formula does work but breaks after to many if and statements. How can I preform the same task just in a better way?

    =IF(sheet1!D2=sheet2!$A$3,AND(sheet1!E2=sheet2!$C$1,sheet2!$C$3)
    ,IF(sheet1!D2=sheet2!$A$3,AND(sheet1!E2=sheet2!$D$1,sheet2!$D$3)
    ,IF(sheet1!D2=sheet2!$A$3,AND(sheet1!E2=sheet2!$E$1,sheet2!$E$3)
    ,IF(sheet1!D2=sheet2!$A$3,AND(sheet1!E2=sheet2!$F$1,sheet2!$F$3)
    ,IF(sheet1!D2=sheet2!$A$4,AND(sheet1!E2=sheet2!$C$1,sheet2!$C$4)
    ,IF(sheet1!D2=sheet2!$A$4,AND(sheet1!E2=sheet2!$D$1,sheet2!$D$4)
    ,IF(sheet1!D2=sheet2!$A$4,AND(sheet1!E2=sheet2!$E$1,sheet2!$E$4)
    ,IF(sheet1!D2=sheet2!$A$4,AND(sheet1!E2=sheet2!$F$1,sheet2!$F$4)
    ,IF(sheet1!D2=sheet2!$A$5,AND(sheet1!E2=sheet2!$C$1,sheet2!$C$5)
    ,IF(sheet1!D2=sheet2!$A$5,AND(sheet1!E2=sheet2!$D$1,sheet2!$D$5)
    ,IF(sheet1!D2=sheet2!$A$5,AND(sheet1!E2=sheet2!$E$1,sheet2!$E$5)
    ,IF(sheet1!D2=sheet2!$A$5,AND(sheet1!E2=sheet2!$F$1,sheet2!$F$5)))))))))))))

    Thanks :P
    Last edited by brentc; 02-17-2009 at 06:18 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: My Giant Formula - I need a better way

    Welcome to the Board.

    Could you explain what exactly this monstrosity is meant to be doing ? I can't make head nor tail of it...

    presently it's saying (excuse annotation)

    =IF(x=y,AND(z=a,s<>0),IF(x=y,z=b,t<>0)....

    which basically makes no sense...

    I suspect perhaps it's meant to be saying

    =IF(AND(x=y,z=a),s,IF(AND(x=y,z=b),t,...)

    Which can be streamlined for sure but we need to understand the aim.

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: My Giant Formula - I need a better way

    funny that ,all i can make it do is return TRUE or possibly False i got bored trying it!

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: My Giant Formula - I need a better way

    I wonder if perhaps the below could replace your formula ?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-17-2009
    Location
    LA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: My Giant Formula - I need a better way

    Quote Originally Posted by DonkeyOte View Post
    Welcome to the Board.

    Could you explain what exactly this monstrosity is meant to be doing ? I can't make head nor tail of it...

    presently it's saying (excuse annotation)

    =IF(x=y,AND(z=a,s<>0),IF(x=y,z=b,t<>0)....

    which basically makes no sense...

    I suspect perhaps it's meant to be saying

    =IF(AND(x=y,z=a),s,IF(AND(x=y,z=b),t,...)

    Which can be streamlined for sure but we need to understand the aim.
    Yes this is very close to what I am trying to accomplish.
    =IF(x=y,AND(z=a,s),IF(x=y,z=b,t) - kind of like this. But still not sure how to write it.
    So let me explain.

    I have a matrix on sheet2 which looks like this:

    Please Login or Register  to view this content.
    Sheet1 I have two columns where each column populates a number from a previous calculation. This number is used in the formula to locate the desired field in the matrix above on Sheet2.
    So if D2 is 2 and E2 is 3 the answer is "no". Again, if D2 is 3 and E2 is 1 the answer would be "nice". So the numbers are only used as reference to where in the matrix it should look up.

    I think that is a bit more clear.

    Thanks all.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: My Giant Formula - I need a better way

    Please see the suggested VLOOKUP formula.

    On an aside... re: IF AND syntax

    =IF(AND(a=b,c=d,e=f),"yes","no")

    So the above return "yes" if a=b and c=d and e=f else "no" would be returned.
    Last edited by DonkeyOte; 02-17-2009 at 05:11 PM.

  7. #7
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: My Giant Formula - I need a better way

    see attached example.
    does that help?
    modytrane
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-17-2009
    Location
    LA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: My Giant Formula - I need a better way

    Thanks for all the help, Vlookup ended up being the answer. I really appreciate it.

+ 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