Extract nonzero data

HMN93

New Member
Joined
May 31, 2014
Messages
20
Hi, I hope you can help me with this.
I have a set of data
Code
Cost
A
10
B
0
C
0
D
15
E
13

<tbody>
</tbody>
How can I extract the nonzero data in the following shape:
A
10
D
15
E
13

<tbody>
</tbody>
Thank you!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Maybe this:

Layout

CodeCost CodeCost
A10 A10
B0 D15
C0 E13
D15
E13
**********************
<colgroup><col width="32" style="width: 24pt; mso-width-source: userset; mso-width-alt: 1170;" span="2"> <col width="17" style="width: 13pt; mso-width-source: userset; mso-width-alt: 621;"> <col width="32" style="width: 24pt; mso-width-source: userset; mso-width-alt: 1170;" span="2"> <tbody> </tbody>

Formula

Code:
In D2 - use Ctrl+Shift+Enter to enter the formula

=IFERROR(INDEX(A$2:A$6,SMALL(IF($B$2:$B$6,ROW($A$2:$A$6)-ROW($A$2)+1),ROWS(D$2:D2))),"")

And copy to the right and down.

Markmzz
 
Upvote 0
Another way:

Layout

CodeCostRow #
CodeCost
A101A10
B04D15
C05E13
D15
E13
***************************

<tbody>
</tbody>

Formulas

Code:
In D2 - use Ctrl+Shift+Enter to enter the formula

=IFERROR(SMALL(IF($B$2:$B$6,ROW($A$2:$A$6)-ROW($A$2)+1),ROWS(D$2:D2)),"")

And copy down.

In E2 - use Enter to enter the formula

=IF($D2="","",INDEX(A$2:A$6,$D2))

And copy to the right and down.

Markmzz
 
Upvote 0
Advanced Filter should do same, but the values are static unlike the formula approach
 
Upvote 0
Hey There HMN93

column Ccolumn D

<tbody>
</tbody>

CodeCost
A10
B0
C0
D15
E13

<tbody>
</tbody>

<tbody>
</tbody>

You could try this too
Code:
=IF(ROWS(C$4:C4)>COUNTIF($D$4:$D$8,">0"),"",INDEX(C$4:C$8,AGGREGATE(15,6,ROW($D$4:$D$8)-ROW($D$4)+1/($D$4:$D$8>0),ROWS(C$4:C4))))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,405
Members
449,448
Latest member
Andrew Slatter

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