+ Reply to Thread
Results 1 to 4 of 4

Count number of cells in range since last number greater than zero

  1. #1
    Registered User
    Join Date
    03-18-2015
    Location
    Newcastle upon Tyne, UK
    MS-Off Ver
    2013
    Posts
    3

    Count number of cells in range since last number greater than zero

    Hi.

    I have a row of numbers that contain usages of a product on a rolling 12 month period. I want to count the number of cells (months) since the item was last used.

    For example, I have the following row of data:

    Product XYZ 2 2 2 2 5 0 1 1 0 2 0 0

    The last column represents the previous month. So in this case, last month, there was no usage and the last time it was used was 3 months ago, because there was no usage last month or the month before.

    What formula could be used to return a "3" as the result to show how many months ago as last used?

    Appreciated!
    Last edited by whitfieldcraig; 03-18-2015 at 06:39 AM.

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Count number of cells in range since last number greater than zero

    Hi,

    Try this -

    =12-LOOKUP(1,0/(B1:M1<>0),COLUMN(B1:M1)-MIN(COLUMN(B1:M1)))

    Assuming your Product name is in the cell A1 and months from B1 to M1

    Cheers!
    Last edited by NeedForExcel; 03-18-2015 at 06:30 AM.
    Cheers!
    Deep Dave

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

    Re: Count number of cells in range since last number greater than zero

    Hi.

    Perhaps an array formula** is the simplest, assuming the numbers are in B1:M1:

    Edit: misread question:

    =COUNT(B1:M1)-MATCH(1,0/(B1:M1<>0))+1

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Last edited by XOR LX; 03-18-2015 at 06:16 AM.
    Click * below if this answer helped

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

  4. #4
    Registered User
    Join Date
    03-18-2015
    Location
    Newcastle upon Tyne, UK
    MS-Off Ver
    2013
    Posts
    3

    Re: Count number of cells in range since last number greater than zero

    Excellent. Thanks for the help.

+ 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. [SOLVED] How to count cells after last number greater than 0
    By gogreenpower in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-09-2014, 02:28 AM
  2. Count number of dates in a range by using greater or less than
    By sclasen24 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-18-2013, 01:29 PM
  3. Replies: 6
    Last Post: 02-24-2012, 01:15 PM
  4. How to Count the Number of Cells Greater than Zero in a Filtered List?
    By denise001 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-01-2011, 11:33 AM
  5. Replies: 3
    Last Post: 05-19-2010, 04:09 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