+ Reply to Thread
Results 1 to 6 of 6

Nested IF enigma.

  1. #1
    Registered User
    Join Date
    01-29-2013
    Location
    texas
    MS-Off Ver
    Excel 2010
    Posts
    68

    Nested IF enigma.

    The below nested if function works:

    =IF(O4<5,IF(O4=1,IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1,K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4,L4/H4),G4*K4/H4),"N/A")

    When I substitute the below if function in the "false" segment of the If len >1

    IF(L4>0,L4/H4,"No YTD")

    to get:

    =IF(O4<5,IF(O4=1,IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1,K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4,IF(L4>0,L4/H4,"No YTD"),G4*K4/H4),"N/A")

    I get the too many arguments error.

    I've messed with it too long now and can't see the forest for the trees.

    Any help appreciated.

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

    Re: Nested IF enigma.

    Maybe just move one of the closed brackets:

    =IF(O4<5,IF(O4=1,IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1,K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4,IF(L4>0,L4/H4,"No YTD",G4*K4/H4)),"N/A")

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    01-29-2013
    Location
    texas
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Nested IF enigma.

    Thanks Pete, but still "too many arguments"

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Nested IF enigma.

    May be you missed a bracket:
    =IF(O4<5,IF(O4=1,IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1,K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4,IF(L4>0,L4/H4,"No YTD")),G4*K4/H4),"N/A")
    Quang PT

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

    Re: Nested IF enigma.

    Okay, well splitting it up and putting in then and else and colour-coding it, you have this:

    =IF(O4<5, then

    IF(O4=1, then

    IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1, then K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4, else

    IF(L4>0,L4/H4, then "No YTD", else G4*K4/H4)),

    else "N/A")

    You can see that the first IF has no matching else or closed bracket.

    Hope this helps.

    Pete

  6. #6
    Registered User
    Join Date
    01-29-2013
    Location
    texas
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Nested IF enigma.

    Thanks bebo for the solution
    and thanks Pete for the diagnostics, I was stumbling for a form of trouble shooting and your answer helps me.

+ 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: 0
    Last Post: 10-01-2012, 05:54 AM
  2. Next without For error in nested loop - Escaping a Nested Loop?
    By BeneRich in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2012, 06:38 PM
  3. For each loop nested; getting stuck on one cell in first iteration of nested loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2009, 11:54 AM
  4. Replies: 6
    Last Post: 01-14-2009, 06:59 PM
  5. help on a nested countif/nested if formula
    By vickiemc in forum Excel General
    Replies: 2
    Last Post: 08-13-2008, 08:29 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