+ Reply to Thread
Results 1 to 8 of 8

LOOKUP and "nesting" IF formula troubles

  1. #1
    Registered User
    Join Date
    07-21-2009
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    LOOKUP and "nesting" IF formula troubles

    Afternoon,

    The enclosed spreadsheet includes a couple formulas I’m having trouble with.
    The questions themselves are detailed in the document.
    Any suggestions would be a big help.
    Attached Files Attached Files
    Last edited by Stubrok; 08-06-2009 at 08:56 AM.

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

    Re: LOOKUP and "nesting" IF formula troubles

    See attached for a proposal...

    I added a helper column to Workbook 1 (column D)

    In D9:

    Please Login or Register  to view this content.
    copied down

    Then in Workbook 2:

    In E20:

    Please Login or Register  to view this content.
    which is confirmed with CTRL+SHIFT+ENTER not just ENTER. Then copied down

    In F20:

    Please Login or Register  to view this content.
    copied down

    In G20:

    Please Login or Register  to view this content.
    copied down

    These formulas can be adjusted to suit your "real ranges"
    Attached Files Attached Files
    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.

  3. #3
    Registered User
    Join Date
    07-21-2009
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: LOOKUP and "nesting" IF formula troubles

    Thanks NBVC. I really appreciate the quick response.

    Wow, these formulas are pretty involved. I'm looking forward to spending some time this morning trying to figure out what all this language means. I have never used some of these functions but I’m excited to see if I can figure them out without further explanation. This website has become a great educational tool for me in a short time. Thanks again to all those involved!

    Of course there is always the chance I come back with a bunch of questions!

    I'll respond once I take a closer look.
    Last edited by NBVC; 08-04-2009 at 08:25 AM.

  4. #4
    Registered User
    Join Date
    07-21-2009
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: LOOKUP and "nesting" IF formula troubles

    It appears that this issue is solved as you have answered all my questions NB. I want to thank you again for taking the time to help me. However, I have to spend more time understanding these formulas in order to apply them effectively.

    I went through the 4 formulas you put together and am still in a fog on some. Here is where my confusion lies:

    Formula #1 – “Neg. Indicator” =MATCH(TRUE,INDEX($F9:$I9<0,0),0)
    Very slick indeed, and quite clever! Taking advantage of the TRUE/FALSE was a great idea.

    Formula #2 – “Item#” =IF(ROWS($E$20:$E20)>SUMPRODUCT(--ISNUMBER($D$9:$D$14)),"",INDEX($E$9:$E$14,SMALL(IF(ISNUMBER($D$9:$D$14),ROW($E$9:$E$14)-ROW($E$9)+1),ROWS($E$20:$E20))))
    I might need some help on this one (either that or a glass of wine to calm my brain down!). Array formulas are new to me so I’m having trouble figuring out why this will not work without the “array” enabled. I’m going to study these more this evening.

    Formula #3 & #4 – “First exception date” =IF(E20="","",INDEX($F$8:$I$8,INDEX($D$9:$D$13,MATCH(E20,$E$9:$E$13,0))))
    and “value” =IF(E20="","",INDEX($F$9:$I$13,MATCH(E20,$E$9:$E$13,0),INDEX($D$9:$D$13,MATCH(E20,$E$9:$E$13,0))))
    I have read about the power of combining MATCH/INDEX but have yet to understand them fully. Also, why is the IF function required if False is always the answer?

    Feel free to help shed some light on what some of this language is effectively doing. In the meantime I’ll be trying to do just that. I will follow up once I do.

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

    Re: LOOKUP and "nesting" IF formula troubles

    Formula # 2:

    The first part of the formula: ROWS($E$20:$E20)>SUMPRODUCT(--ISNUMBER($D$9:$D$13)) checks to see if the row number you're in is greater than the number of numeric entries...if it is greater then a blank is inserted (so no errors are visible). Note: I didn't use Countif() because you are working with separate workbooks and Countif() doesn't work on closed workbooks.

    The next part: INDEX($E$9:$E$13,SMALL(IF(ISNUMBER($D$9:$D$13),ROW($E$9:$E$13)-ROW($E$9)+1),ROWS($E$20:$E20)))

    is like a vlookup for multiple matches... It uses the Index() function which requires you to index the table or column to extract from and it requires the Row number to extract from which is gotten from this part: SMALL(IF(ISNUMBER($D$9:$D$13),ROW($E$9:$E$13)-ROW($E$9)+1),ROWS($E$20:$E20))

    The Small() function just allows us to step up and extract one match at a time, starting from the first match found. It will extract only if a number is found in range $D$9:$D$13 and then it will return the corresponding row number within the range. The -ROW($E$9)+1 is added for robustness (incase you insert rows above, then the result won't skew).

    The last ROWS($E$20:$E20) is the k factor for the Small() function, which is like a step factor in a For...next loop in VBA.

    The CSE confirmation is because it is an array formula and you have to confirm with those keys to make these formulas work.

    More on Array Formulas here.

    Then you copy down... The only thing that changes copying down is the ROWS($E$20:$E20) in the 2 occurances within the formula.. again to determine the step or row number we're in.

    Formula 3 & 4:

    Index and Match is like using Vlookup or Vlookup and Hlookup together to find an intersection point in a table...where the lookup values are the Row and/or Column headers... the syntax of Index() is INDEX(Table,Row_number,Column_Number). The Row Number can be found by using the MATCH() function.. which looks up an item in a vertical range and returns the vertical position. The Column_number too can use the Match() function to lookup an item in a horizontal range and return a position.. these two positions act as intersection points and returns the value at that intersection in the indexed table... In this case I just embedded another Index/Match function to find the column position.... Note that the column_number argument (or row_number) is optional if you select a column only or row only as the indexed table... as I did when determining the column_number.

    The IF() function was simply used to return a blank if there is nothing in E20 down... otherwise you would get an #N/A error instead of a clean looking blank.

    Hope this helps.
    Last edited by NBVC; 08-04-2009 at 05:05 PM.

  6. #6
    Registered User
    Join Date
    07-21-2009
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: LOOKUP and "nesting" IF formula troubles

    Quick question regarding a portion of the formula below:

    =IF(ROWS($E$20:$E24)>SUMPRODUCT(--ISNUMBER($D$9:$D$14)),"",INDEX($E$9:$E$14,SMALL(IF(ISNUMBER($D$9:$D$14),ROW($E$9:$E$14)-ROW($E$9)+1),ROWS($E$20:$E24))))

    "IF(ROWS($E$20:$E24)>SUMPRODUCT(--ISNUMBER($D$9:$D$14))"

    If the range in column D ($D$9:$D$14) contains less values to count than the number of rows being counted in column E ($E$20:$E24) then the result would be true even though there is a negative value to report.

    I enclosed an example. The cells I'm working with are E44,45 and 46.

    There is a good chance I overlooked something here. I'm having a harder time deciphering how all this fits together than I thought.
    Attached Files Attached Files

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

    Re: LOOKUP and "nesting" IF formula troubles

    I noticed that the last set of entries in "workbook 1" are in row 14...

    ... you formula in E20 reflects that, but none of the other formulas in E21 down and in F20 (down and across) reflect that... instead they reflect a range ending at row 13 in "Workbook 1".

    Is that the issue?

  8. #8
    Registered User
    Join Date
    07-21-2009
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: LOOKUP and "nesting" IF formula troubles

    You are quick NB, I just noticed that myself but you responded before I could!

    Everything seems to be working correctly now.

+ 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