+ Reply to Thread
Results 1 to 13 of 13

how to get first non zero value in an array and display all values after that

  1. #1
    Registered User
    Join Date
    10-22-2016
    Location
    USA
    MS-Off Ver
    2003
    Posts
    5

    how to get first non zero value in an array and display all values after that

    Hello,
    Hoping someone can help me.
    I need to check a row full of numerical values. What is the formula to retrieve the first non-zero value and then display all values after that in original order.
    Thank you!

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: how to get first non zero value in an array and display all values after that

    Try

    Assuming data in column A

    in B1

    =IFERROR(INDEX(A:A,SMALL(IF($A$1:$A$100<>0,ROW($A$1:$A$100),""),ROWS($A$1:A1))),"")

    Enter with Ctrl+Shift+Enter

    Drag down until you get blank cells.
    Last edited by JohnTopley; 10-23-2016 at 03:28 AM.

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: how to get first non zero value in an array and display all values after that

    What version of Excel does this have to work in?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,909

    Re: how to get first non zero value in an array and display all values after that

    For Excel 2003:

    =IF(ROWS($A$1:A1)>COUNTIF($A$1:$A$100,">0"),"",
    INDEX(A:A,SMALL(IF(ISNUMBER($A$1:$A$100)*($A$1:$A$100<>0),ROW($A$1:$A$100),""),ROWS($A$1:A1))))

    Enter with Ctrl+Shift+Enter
    Last edited by Phuocam; 10-22-2016 at 08:00 PM.

  5. #5
    Registered User
    Join Date
    10-22-2016
    Location
    USA
    MS-Off Ver
    2003
    Posts
    5

    Re: how to get first non zero value in an array and display all values after that

    thanks all for your replies. It seems your responses assume my data is in column A. how would the formula look like if the data array in in row 2 starting in cell C2 ending in BV2
    I used this formula to find the first value above 0 in row 2, my challenge is to find and display all values after this one (in the original order).

    =INDEX(C$2:BV$2,MATCH(TRUE,INDEX(C$2:BV$2>0,),0))

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: how to get first non zero value in an array and display all values after that

    Try

    =IFERROR(INDEX($C$2:$BV$2,SMALL(IF($C2:$BV2<>0,COLUMN($C$2:$BV$2)-COLUMN($C$2)+1,""),COLUMNS($C:C))),"")

    Enter with Ctrl+Shift+Enter

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: how to get first non zero value in an array and display all values after that

    I'll ask again, what version of Excel does this have to work in?

    If this was your data:

    Data Range
    C
    D
    E
    F
    G
    H
    I
    J
    1
    ----
    ----
    ----
    ----
    ----
    ----
    ----
    ----
    2
    0
    0
    22
    0
    6
    41
    0
    15


    What results do you expect?

    Do you want: 22, 6, 41, 15 or, do you want: 22, 0, 6, 41, 0, 15?

    Also, where do you want these results to appear? Across a row? Down a column? Tell us the cell address of the first cell where the results should appear and what direction it should follow.

  8. #8
    Registered User
    Join Date
    10-22-2016
    Location
    USA
    MS-Off Ver
    2003
    Posts
    5

    Re: how to get first non zero value in an array and display all values after that

    Thank you all! I appreciate your help!! I transposed the data and used the formula with Row. Have a great Sunday! and I learned something NEW!

  9. #9
    Registered User
    Join Date
    10-22-2016
    Location
    USA
    MS-Off Ver
    2003
    Posts
    5

    Re: how to get first non zero value in an array and display all values after that

    I have Microsoft Office Professional 2010

  10. #10
    Registered User
    Join Date
    10-22-2016
    Location
    USA
    MS-Off Ver
    2003
    Posts
    5

    Re: how to get first non zero value in an array and display all values after that

    I expect data to appear in K2 and the result is 22, 0, 6, 41, 0, 15

    As noted -- thanks all-- I got my result. Appreciate it.

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: how to get first non zero value in an array and display all values after that

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: how to get first non zero value in an array and display all values after that

    Good deal. Thanks for the feedback!

  13. #13
    Registered User
    Join Date
    05-07-2020
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    1

    Re: how to get first non zero value in an array and display all values after that

    Hi - looking for assistance with the same issue. I want my output to be 22, 0, 6, 41, 0, 15 and I use version Professional Plus 2013. I havent had any luck with the above formulas and I can't transpose my data.
    My data is across a row and I want it to be displayed across a row (22, 0, 6, 41, 0, 15).
    Thanks.
    Last edited by gdowbiggin; 05-07-2020 at 01:55 PM.

+ 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. Filling array with several values and extent array using these values
    By Martijn79 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-30-2015, 07:11 AM
  2. Display only unique values in an array
    By jrm0523 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-16-2012, 03:37 AM
  3. [SOLVED] Count consecutive non-zero values; list first non-zero value; display counts as an array
    By treznick in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-17-2012, 08:25 PM
  4. Display an array of values from a column range
    By alexandruc in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 02-12-2012, 03:06 PM
  5. Find a value in an array and return multiple values in an adjacent array
    By tonbra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2012, 08:35 PM
  6. Display Values of Column/Range/Array/Other
    By Laelsa in forum Excel General
    Replies: 1
    Last Post: 11-21-2008, 08:42 PM
  7. Display Values of Column/Range/Array/Other
    By Laelsa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-21-2008, 03:06 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