+ Reply to Thread
Results 1 to 4 of 4

Require a function to return a last non zero value in a column

  1. #1
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Question Require a function to return a last non zero value in a column

    Formula using LOOKUP function is not working for values generated from calculations in a column. I need to find the last non zero value.
    I have used the formula
    =LOOKUP(9.99E+307,1/(C9:C208<>0),C9:C208)
    the column C has values that are calculated based on other cells in the sheet.
    Attached with this message and also at the following links is my excel file.Every thing is described in the file Urgent.....

    http://www.filedropper.com/myrequirement
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Require a function to return a last non zero value in a column

    Here, try this:

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

  3. #3
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Require a function to return a last non zero value in a column

    Thanx a ton for the help!! was struck with it since a week! works like a miracle!!
    Any further issues, I will post, but as of now It's working fine!!
    Thanx again!!

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Require a function to return a last non zero value in a column

    Hi,

    There's absolutely nothing wrong with this solution:

    =LOOKUP(9.99E+307,1/($C$9:$C$208<>0)/($C$9:$C$208<>""),$C$9:$C$208)

    However, it always strikes me as slightly illogical, and perhaps also habitual? Again, there's nothing wrong with this, but perhaps for the sake of interested readers of this post wondering about these constructions with a so-called "big number", I thought I would just take the opportunity to point out that, in this particular example, its use is not at all necessary, and perhaps also slightly counter-intuitive.

    Having said that, I can understand why it is taught that this value should be used, particularly in cases where the 'last number in a range is being sought', etc., etc., and I'm not trying to say that it shouldn't be, just that, well, let me explain...

    Since the array returns for ($C$9:$C$208<>0) and ($C$9:$C$208<>"") will consist of TRUE/FALSE only, when we calculate:

    ($C$9:$C$208<>0)/($C$9:$C$208<>"")

    we will get something along the lines of, for example:

    {TRUE;FALSE;FALSE;TRUE;TRUE;TRUE;FALSE;TRUE;...}/{TRUE;FALSE;FALSE;TRUE;TRUE;TRUE;FALSE;TRUE;...}

    which will evaluate to:

    {1;0;#DIV/0!;1;1;1;#DIV/0!;1;...}

    Hence, since when we next take the reciprocal of this array of values (from 1/($C$9:$C$208<>0)/($C$9:$C$208<>"")):

    {1;#DIV/0!;#DIV/0!;1;1;1;#DIV/0!;1;1;#DIV/0!;1;#DIV/0!;...}

    we will only ever get either a 1 or a #DIV/0!. In fact, this will always be the case, as you can easily verify.

    The point is then, that unlike if we were passing an array of arbitrarily large numbers to the LOOKUP function, in which case this 'big number' is justified (and necessary), here, since our largest value can only ever be 1, it is sufficient to write:

    =LOOKUP(2,1/($C$9:$C$208<>0)/($C$9:$C$208<>""),$C$9:$C$208)

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

+ 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: 4
    Last Post: 03-13-2013, 12:38 PM
  2. [SOLVED] A loop - Require Some If Magic to return output
    By lifeisaspreadsheet in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 10-12-2012, 02:36 PM
  3. Require a return of Complete or incomplete base on information in a cell
    By ROB40160 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-12-2012, 11:17 AM
  4. Require formula to return value of hours worked in tenths.
    By ChuckFerrera in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2012, 12:12 PM
  5. [SOLVED] Require a lookup to return multiple values
    By Matt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2005, 05:06 PM

Tags for this Thread

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