bottom
Great ExcelTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > ExcelTips Home > Formulas > Segregating Numbers According To Their Sign

Segregating Numbers According To Their Sign

Summary: If you have a bunch of numbers—some positive and some negative—you may want to obtain a list of only those numbers below or above zero. There are several ways you can get this information, as described here. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)

Are you working with a large set of data consisting of mixed values, some negative and some positive, that you want to separate into columns based on their sign? There are several ways this can be approached. One method is simply to use a formula in the columns to the right of the mixed column. For instance, if the mixed column is in column A, then you could place the following formula in the cells of column B:

=IF(A2>0,A2,0)

This results in column B only containing values that are greater than zero. In column C you could then use this formula:

=IF(A2<0,A2,0)

This column would only contain values less than zero. The result is two new columns (B and C) that are the same length as the original column. Column B is essentially the same as column A, except that negative values are replaced by zero, while column C replaces positive values with zero.

If you want to end up with columns that only contain negative or positive values (no zeroes), then you can use the filtering capabilities of Excel. Assuming the mixed values are in column A, follow these steps:

  1. If you have a column heading in cell A1, copy it to cell E1.
  2. In cell E2, place the formula >0.
  3. Select any cell in the mixed values of column A.
  4. Choose Filter from the Data menu, then choose Advanced Filter from the resulting submenu. Excel displays the Advanced Filter dialog box. (Click here to see a related figure.) (To display the dialog box in Excel 2007, display the Data tab of the ribbon and click Advanced within the Sort & Filter group.) The List Range should already be filled in, representing the range of mixed values in Column A.
  5. Make sure the Copy to Another Location radio button is selected.
  6. Select the Criteria Range box and then use the mouse to select cells E1:E2. This tells Excel that you only want cells in the original range that are greater than zero.
  7. Select the Copy To box and click once in cell B1.
  8. Click on OK. Column B now contains cells that are greater than zero.
  9. In cell E2, place the formula <0.
  10. Again choose Filter from the Data menu, then choose Advanced Filter from the resulting submenu. Excel displays the Advanced Filter dialog box. The settings in the dialog box should be the same as the last time you used them.
  11. Select everything in the Copy To box, and then click once in cell C1.
  12. Click on OK. Column C now contains cells that are less than zero.

You now have the desired two columns of positive and negative values. You can also delete the cells at E1:E2 if you desire.

Tip #3198 applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007


Save Time! ExcelTips has been published weekly since late 1998. Past issues of ExcelTips are available in convenient ExcelTips archives. Have your own enhanced archive of ExcelTips at your fingertips, available to use at any time!
 
Check out ExcelTips Archives today!

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home
Vital News Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

 

Great Info!

Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)