How to select the second non zero/blank value in a range?

Addenum

New Member
Joined
Jun 12, 2013
Messages
7
Here is an example row of data, with 8 values:

0,[blank],0,1,0,0,[blank],5

We are trying to find a formula that finds the second non zero or non blank value, which in this case is 5. (Ideally this should also be able to be configured to find the third or later non zero non blank value too).

Does anyone have any solution to this?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi and welcome to MrExcel.

This may not be the best solution, but, does this work for you?.....

Sample data and example result with a "Helper" column.

Excel Workbook
ABCDEF
1DataHelperResult
20 25
3
40
511
60
70
8
952
10
Sheet6


The formula in B2 needs to be copied down.
You will need to change the cell references to suit your layout.

You can put any number you like in cell D2 to return the Nth number that is not zero of blank.

I hope that helps.

Ak
 
Upvote 0
Hi..

I know you asked for a formula.. but in case you decide you need a VBA solution...

Code:
Private Sub CommandButton1_Click()
Dim i As Long, Cnt As Long, LastCol As Long
LastCol = Sheets("Sheet1").Cells(1, Columns.Count).End(xlToLeft).Column
Cnt = 0
For i = 1 To LastCol
If Cells(1, i).Value <> 0 And Cells(1, i).Value <> "" Then
Cnt = Cnt + 1
End If
If Cnt = 2 Then
Cells(5, 2).Value = Cells(1, i).Value
End If
Next i
End Sub

Sheet1

*ABCDEFGH
10*0100*5
2********
3********
4********
5Result5******

<tbody>
</tbody>

Excel tables to the web - Excel Jeanie Html 4

btw.. anyone know why Excel Jeanie puts an asterix where blank spaces are for me but not for Akashwani?
 
Last edited:
Upvote 0
Hi apo,

You get asterix when you have edited your comment. I delete and repaste my data to avoid the dreaded *.

Ak
 
Upvote 0
Hey Thanks for writing:
I have your data in cells A1:A7, and in any other cell you can use the following formula:

=IF(SUM(--((A1:A7)>0)*ROW(A1:A7))=2,INDEX(A1:A7,LARGE(((A1:A7)>0)*ROW(A1:A7),1)),INDEX(A1:A7,LARGE(((A1:A7)>0)*ROW(A1:A7),2)))

Please make sure you press Control + Shift + Enter while entering the formula since this is an array operation.

Hope this helps.

Thanks/Raj
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,375
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top