setting negative values to zero in a column

L

libertyforall

I have a column of data and occassionally there is a negative number.
I want to set all the negative numbers in the column to zero without
changing the positive numbers and without doing it manually for each
cell. How do I do this?
 
A

AltaEgo

1) Change your formula to add a condition so you don't get negative numbers:

=If(yourFormula<0,0,yourFormula)

You would need to put this into cells with existing formula that return
numbers <0. In place of 'yourFormula' in the above, substitute the existing
formula in you cell (without the equal sign).

Example if Cell C1 contained =A1-A2, your new formula would become
=IF(A1-A2<0,0,A1-A2)

2) Format cells with a custom format. The following will change the font
colour of negative numbers to white. Negative values will appear as a dash
in the cell. If you click on the cell, you can see the number in the
formula bar. Any dependant cell will have access to the hidden negative
number.

#,##0;-


If you don't wish to see the dash the customs format is

#,##0;

If you want a word:

#,##0;"negative"

3) VBA - avoid if possible

Sub SetNegToZero()
' warning if cell value is negative
' this will overwrite existing cell formula

Dim C

For Each C In Selection
If C.Value < 0 Then C.Value = 0
Next C
End Sub
 
D

DILipandey

Use the following custom format
###############;<space>

--
Click on Yes, if it is useful.

Thanks & Best Regards,
Dilip Kumar Pandey
MBA, BCA, B.Com(Hons.)
(e-mail address removed)
(e-mail address removed)
New Delhi, India
 
R

RagDyeR

Custom format:

General;""

--

HTH,

RD
=====================================================
Please keep all correspondence within the Group, so all may benefit!
=====================================================

I have a column of data and occassionally there is a negative number.
I want to set all the negative numbers in the column to zero without
changing the positive numbers and without doing it manually for each
cell. How do I do this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top