# Extracting non-zero values

#### Tweetie85

##### New Member
Hi

A previous thread explained how to pull non-zero values from a column of values

The code I then used from this thread is as follows:
=IF(ROWS(B\$1:B1)>COUNTIF(A\$1:A\$1200,">0"),"",INDEX(A\$1:A\$1200,SMALL(IF(A\$1:A\$1200>0,ROW(A\$1:A\$1200)-ROW(A\$1)+1),ROWS(B\$1:B1))))
The logic behind it is explained in the thread....

This code works great but I need it to apply to negative numbers as well. I posted the question there but have not got a reply as yet.

Would anyone be able to figure this out for me? I would be very grateful!

### Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

#### xld

##### Banned
Untested

=IF(ROWS(B\$1:B1)>COUNTIF(A\$1:A\$1200,"<>0"),"",INDEX(A\$1:A\$1200,SMALL(IF(A\$1:A\$1200>0,ROW(A\$1:A\$1200)-ROW(A\$1)+1),ROWS(B\$1:B1))))

#### pgc01

##### MrExcel MVP
Hi

Assuming there may be blanks, use in B1:

=IF(ROWS(B\$1:B1)>SUMPRODUCT(--(A\$1:A\$1200<>0),--ISNUMBER(\$A\$1:\$A\$1200)),"",INDEX(A\$1:A\$1200,SMALL(IF((A\$1:A\$1200<>0)*ISNUMBER(A\$1:A\$1200),ROW(A\$1:A\$1200)-ROW(A\$1)+1),ROWS(B\$1:B1))))

This in an array formula, you have to confirm it with CTRL+SHIFT+ENTER.

Copy down

#### Tweetie85

##### New Member
Thanks guys

Both lines of code work. But to avoid a #NUM! error at the very end of the formula (for xld's code), change the it to the following:

=IF(ROWS(B\$1:B1)>COUNTIF(A\$1:A\$1200,"<>0"),"",INDEX(A\$1:A\$1200,SMALL(IF(A\$1:A\$1200<>0,ROW(A\$1:A\$1200)-ROW(A\$1)+1),ROWS(B\$1:B1))))

Thanks guys, really appreciate it!!

Replies
10
Views
368
Replies
1
Views
296
Replies
24
Views
799
Replies
4
Views
513
Replies
1
Views
207

1,190,996
Messages
5,984,060
Members
439,872
Latest member
noaman79

### 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.

### Which adblocker are you using?

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

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