+ Reply to Thread
Results 1 to 7 of 7

Merging formula not working

  1. #1
    Registered User
    Join Date
    02-13-2014
    Location
    San Francisco, USA
    MS-Off Ver
    Excel 365
    Posts
    34

    Merging formula not working

    I have 2 conditions (CaseA and CaseB) that I need to merge but the merging formula is not working, it returns #VALUE!. They are working separately, however. Any suggestion is highly appreciated. The file is attached herewith.

    For CaseA:
    =IF($B2="CaseA",IF($D2<24,"Invalid",IF(AND($E2<34,$D2>=24,$D2<336,$C2>=0),"Indeterminate",IF(AND($E2<34,$D2>336,$C2>5.5),"Normal",IF(AND($E2<34,$D2>336,$C2<5.5),"High Risk",IF(AND($E2>=34,$D2>=24,$C2>10),"Normal",IF(AND($E2>=34,$D2>=24,$D2<167,$C2>8,$C2<=10),"Borderline",IF(OR(AND($E2>=34,$D2>=24,$D2<=167,$C2<8),AND($E2>=34,$D2>=168,$D2<=335,$C2<6),AND($E2>=34,$D2>=336,$C2<5.5)),"Refer"))))))))

    For CaseB:
    =IF($B2="CaseB",IF($D2<24,"Invalid",IF(AND($E2<34,$D2>=24,$D2<336,$C2>=0),"Indeterminate",IF(AND($E2<34,$D2>336,$C2>3.2),"Normal",IF(AND($E2<34,$D2>336,$C2<3.2),"High Risk",IF(AND($E2>=34,$D2>=24,$C2>6),"Normal",IF(AND($E2>=34,$D2>=24,$D2<168,$C2>4,$C2<=6),"Borderline",IF(OR(AND($E2>=34,$D2>=24,$D2<=167,$C2<4),AND($E2>=34,$D2>=168,$D2<=335,$C2<3.6),AND($E2>=34,$D2>=336,$C2<3.2)),"Refer"))))))))

    Merged:
    =IF($B2="CaseA",IF($D2<24,"Invalid",IF(AND($E2<34,$D2>=24,$D2<336,$C2>=0),"Indeterminate",IF(AND($E2<34,$D2>336,$C2>5.5),"Normal",IF(AND($E2<34,$D2>336,$C2<5.5),"High Risk",IF(AND($E2>=34,$D2>=24,$C2>10),"Normal",IF(AND($E2>=34,$D2>=24,$D2<167,$C2>8,$C2<=10),"Borderline",IF(OR(AND($E2>=34,$D2>=24,$D2<=167,$C2<8),AND($E2>=34,$D2>=168,$D2<=335,$C2<6),AND($E2>=34,$D2>=336,$C2<5.5)),"Refer")))))))), IF($B2="CaseB",IF($D2<24,"Invalid",IF(AND($E2<34,$D2>=24,$D2<336,$C2>=0),"Indeterminate",IF(AND($E2<34,$D2>336,$C2>3.2),"Normal",IF(AND($E2<34,$D2>336,$C2<3.2),"High Risk",IF(AND($E2>=34,$D2>=24,$C2>6),"Normal",IF(AND($E2>=34,$D2>=24,$D2<168,$C2>4,$C2<=6),"Borderline",IF(OR(AND($E2>=34,$D2>=24,$D2<=167,$C2<4),AND($E2>=34,$D2>=168,$D2<=335,$C2<3.6),AND($E2>=34,$D2>=336,$C2<3.2)),"Refer"))))))))
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Merging formula not working

    Maybe solved already from the above comment? But if not, you have a bracket in the wrong place. Delete one closing bracket from the end of the first IF statement (just before IF($B2="CaseB") and add one to the end of the formula, then it works.

  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,946

    Re: Merging formula not working

    If you only have 2 choices for the Case, you dont need the IF($B2="CaseB"...part

    it would read something like...
    =IF($B2="CaseA",IF($D2<24,"Invalid",IF(AND($E2<34,$D2>=24,$D2<336,$C2>=0),"Indeterminate",IF(AND($E2<34,$D2>336,$C2>5.5),"Normal",IF(AND($E2<34,$D2>336,$C2<5.5),"High Risk",IF(AND($E2>=34,$D2>=24,$C2>10),"Normal",IF(AND($E2>=34,$D2>=24,$D2<167,$C2>8,$C2<=10),"Borderline",IF(OR(AND($E2>=34,$D2>=24,$D2<=167,$C2<8),AND($E2>=34,$D2>=168,$D2<=335,$C2<6),AND($E2>=34,$D2>=336,$C2<5.5)),
    IF($D2<24,"Invalid",IF(AND($E2<34,$D2>=24,$D2<336,$C2>=0),"Indeterminate",IF(AND($E2<34,$D2>336,$C2>3.2),"Normal",IF(AND($E2<34,$D2>336,$C2<3.2),"High Risk",IF(AND($E2>=34,$D2>=24,$C2>6),"Normal",IF(AND($E2>=34,$D2>=24,$D2<168,$C2>4,$C2<=6),"Borderline",IF(OR(AND($E2>=34,$D2>=24,$D2<=167,$C2<4),AND($E2>=34,$D2>=168,$D2<=335,$C2<3.6),AND($E2>=34,$D2>=336,$C2<3.2)),"Refer"))))))))

    untested, so may have some ) missing at the end, and the whol;e thing copuld probably be simplified a bit.
    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
    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,946

    Re: Merging formula not working

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

  5. #5
    Registered User
    Join Date
    02-13-2014
    Location
    San Francisco, USA
    MS-Off Ver
    Excel 365
    Posts
    34

    Re: Merging formula not working

    Thank you so much, FDibbins.

  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,946

    Re: Merging formula not working

    Happy to help

  7. #7
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Merging formula not working

    It certainly looks like it could be made shorter. Also there are some "gaps" in the logic. Firstly there are some cases where the > and <= values either overlap or leave gaps.

    Secondly, the following values are not dealt with:

    C<0 when D<336 and E<34
    C between 6 and 10 when D>=168 and E>=34
    C between 5.5 and 10 when D>=336 and E>=34

    I've made the boundaries consistent and put the criteria in tables. Then the combined formula is:

    Please Login or Register  to view this content.
    Admittedly not that much shorter but it does make it a million times easier to see what's going on and to change things. It gives the same results as your examples.
    Attached Files Attached Files

+ 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. Replies: 1
    Last Post: 11-02-2017, 09:20 PM
  2. Format a part of a text working with only value not working with formula result
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2017, 05:41 AM
  3. Replies: 3
    Last Post: 05-14-2015, 07:32 AM
  4. Correct/Working (Index,Match) formula not working between cells
    By barnerd in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 02-11-2014, 01:20 PM
  5. Replies: 9
    Last Post: 03-08-2013, 11:50 AM
  6. Replies: 2
    Last Post: 08-17-2012, 08:16 AM
  7. Merging: displaying which sheet data comes from when merging sheets
    By zed commander in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-12-2012, 12:20 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