+ Reply to Thread
Results 1 to 7 of 7

Excel 2007 : Find last non- zero item in a row of values

  1. #1
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Find last non- zero item in a row of values

    I have a random assortment of static values ranging from 0-5 in cells C3:Y3. How do I locate the highest column number containing a non zero? I've tried:
    Please Login or Register  to view this content.
    Which of course will locate the first 0 and return the position in the array. Note that zeros may appear in the row more than once, followed by non zero values:
    0,1,5,0,0,5,2,3,0,0,0,0,5,3,4,3,2,0,0,1,0,0,0

    In the above sample, the 20th item in the array is a 1 which is what I'd like to return the position for.
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Find last non- zero item in a row of values

    Hi look into attachment
    Attached Files Attached Files
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Find last non- zero item in a row of values

    Non-array formula solution:
    =LOOKUP(2,1/(C3:Y3<>0),ROW(INDIRECT("1:"&COUNTA(C3:Y3))))
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Find last non- zero item in a row of values

    Tom1977, that was perfect! Tigeravatar, when I get a chance I'll check your solution out also...Thanks!

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Find last non- zero item in a row of values

    This should also work, it finds the relative position in the range

    =MATCH(2,INDEX(1/(C3:Y3<>0),0))
    Audere est facere

  6. #6
    Registered User
    Join Date
    05-02-2014
    Location
    Israel
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Find last non- zero item in a row of values

    Quote Originally Posted by daddylonglegs View Post
    This should also work, it finds the relative position in the range

    =MATCH(2,INDEX(1/(C3:Y3<>0),0))
    That is Genius
    Could you please explain how that works.

  7. #7
    Registered User
    Join Date
    09-13-2013
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2013
    Posts
    1

    Re: Find last non- zero item in a row of values

    daddylonglegs, I am also interested in understanding how this works. I have used MATCH and INDEX, but I do not how the portion after INDEX; specifically, I am not familiar with dividing 1 by a range of non-zero numbers. I have not been able to find an explanation online. Would you mind pointing me to where I could find an explanation or sharing how this works?

    Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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