+ Reply to Thread
Results 1 to 13 of 13

Large Nested If Statements: how to improve?

  1. #1
    Registered User
    Join Date
    11-09-2022
    Location
    Alabama
    MS-Off Ver
    Office365
    Posts
    4

    Large Nested If Statements: how to improve?

    Hello. I searched the forum for previous posts on the topic ("nested if") and found several that might have been helpful. However, when I open the thread it is blank inside. I would like to know if there is a way to simplify my If formula/statement.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I apologize for the long line. I am not sure how to line break the formula. I am also attaching a sample workbook displaying functionality. I have several similar formulas (formulae?). Any assistance would be greatly appreciated.
    Attached Files Attached Files
    Last edited by AliGW; 11-09-2022 at 05:53 AM. Reason: Thread title improved - please make your thread titles explicit & not generic in future.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,296

    Re: Large Nested If Statements

    Welcome to the forum.

    Rather than us having to reverse engineer a long formula, please explain in WORDS what the formula is doing (the logic).
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,296

    Re: Large Nested If Statements

    This should give you the correct answer:

    =SUMPRODUCT((Fees!$B$2:$C$14)*(Fees!$A$2:$A$14=C2)*(RIGHT(Fees!$B$1:$C$1,3)=B2))*D2

    Two of your original calculations seem to be taking a value from the WRONG B2 column.
    Attached Files Attached Files
    Last edited by AliGW; 11-09-2022 at 05:53 AM.

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Large Nested If Statements: how to improve?

    Try this:

    =IF(OR($B2="B2B",$B2="B2C"),VLOOKUP($C2,Fees!$A$2:$D$14,3,)*$D2,"not defined")

    Hope this helps.

    Pete

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Large Nested If Statements: how to improve?

    Please try in E2 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-09-2022
    Location
    Alabama
    MS-Off Ver
    Office365
    Posts
    4

    Re: Large Nested If Statements: how to improve?

    Thank you all for the assistance with this. I now have multiple ways to simplify the formula. Thanks.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,296

    Re: Large Nested If Statements: how to improve?

    Glad to have helped.

    If you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  8. #8
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Large Nested If Statements: how to improve?

    Glad to help, thanks for your feedback and rep .
    Last edited by HansDouwe; 11-09-2022 at 08:47 AM.

  9. #9
    Registered User
    Join Date
    11-09-2022
    Location
    Alabama
    MS-Off Ver
    Office365
    Posts
    4

    Re: Large Nested If Statements: how to improve?

    AliGW - I arranged the columns in the test worksheet to mirror my actual sheet (I had simplified it for the post). Yours still works perfectly, while mine give the value as $0.00. I have made a copy of the worksheets from my original. I cannot figure out how I messed it up. I should not that the InvoiceExport sheet inherits values from a sheet called InvoiceImport. Not sure if that makes a difference.

    HansDouwe - I also tried it your way and go no result either. I am thinking that it is the operator.
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,296

    Re: Large Nested If Statements: how to improve?

    E2 contains text, not a number, so there is a mismatch. Try this:

    =SUMPRODUCT((Fees!$C$2:$D$14)*(Fees!$A$2:$A$14=E2+0)*(RIGHT(Fees!$C$1:$D$1,3)=N2))*D2

  11. #11
    Registered User
    Join Date
    11-09-2022
    Location
    Alabama
    MS-Off Ver
    Office365
    Posts
    4

    Re: Large Nested If Statements: how to improve?

    That was it! Thank you, thank you, thank you!

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,296

    Re: Large Nested If Statements: how to improve?

    You are most welcome.

  13. #13
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Large Nested If Statements: how to improve?

    The same will also apply to my formula. If you apply this in your last workbook, you will also have to change E2 to --E2 or 1*E2 or 0+E2 or E2*1 or E2+0

+ 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. Formula with nested IF statements & AND statements
    By Hollywood44 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-11-2018, 03:38 PM
  2. "Large" Function w. Nested If Statements Error
    By thecartyparty1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-15-2015, 07:22 PM
  3. [SOLVED] Nested if statements containing multiple and statements
    By John M. in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-22-2014, 11:48 PM
  4. questions with if statements and nested if statements
    By Pat Excel in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-03-2013, 01:41 PM
  5. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  6. Nested If statements / logic statements
    By Brainless_09 in forum Excel General
    Replies: 3
    Last Post: 06-17-2009, 02:59 PM
  7. Replies: 12
    Last Post: 05-15-2009, 08:38 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