+ Reply to Thread
Results 1 to 16 of 16

Count number of cells between first and last non-zero value in row

Hybrid View

  1. #1
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,492

    Re: Count number of cells between first and last non-zero value in row

    Welcome to the forum!

    Try this:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    1
    0
    0
    4
    5
    0
    0
    2
    3
    0
    0
    0
    2
    3
    6
    Sheet: Sheet1

    Excel 2016 (Windows) 32 bit
    B
    3
    =(LOOKUP(2,1/(1:1>0),COLUMN(1:1))+1)-(MATCH(1,1:1,1)+1)
    Sheet: Sheet1
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  2. #2
    Registered User
    Join Date
    11-25-2018
    Location
    Bangalore, India
    MS-Off Ver
    365
    Posts
    2

    Re: Count number of cells between first and last non-zero value in row

    Thanks! Could you pls explain how that worked?

  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 between first and last non-zero value in row

    Quote Originally Posted by AliGW View Post
    Welcome to the forum!

    Try this:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    1
    0
    0
    4
    5
    0
    0
    2
    3
    0
    0
    0
    2
    3
    6
    Sheet: Sheet1

    Excel 2016 (Windows) 32 bit
    B
    3
    =(LOOKUP(2,1/(1:1>0),COLUMN(1:1))+1)-(MATCH(1,1:1,1)+1)
    Sheet: Sheet1
    What happens if, for example, the first and last entries are non-zero and all the rest zero?

    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. how to count number of blank cells on a column up to a number value is typed
    By carlosnixon in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-25-2018, 02:46 AM
  2. how to count number of blank cells on a column up to a number value is typed
    By carlosnixon in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-25-2018, 01:01 AM
  3. [SOLVED] How to count *backwards* the number of blank cells until a number reached
    By lamlam28 in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 05-06-2018, 11:34 PM
  4. [SOLVED] Count number of cells in range since last number greater than zero
    By whitfieldcraig in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-18-2015, 06:38 AM
  5. count number of cells since value exceeded some number
    By abhijith_ca in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-25-2013, 12:58 AM
  6. Replies: 2
    Last Post: 08-16-2010, 10:44 AM
  7. Count number of times a specific number is displayed in cells
    By subs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2005, 11:05 AM

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