ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If Cell Value < 0, Change Value to 0 (https://www.excelbanter.com/excel-worksheet-functions/62388-if-cell-value-0-change-value-0-a.html)

tcgaines

If Cell Value < 0, Change Value to 0
 

The subject says it all. I want to search a range for cell values that
are < 0 and if they are, change the value to 0. how do i do that?

thx


--
tcgaines
------------------------------------------------------------------------
tcgaines's Profile: http://www.excelforum.com/member.php...o&userid=29608
View this thread: http://www.excelforum.com/showthread...hreadid=496840


tcgaines

If Cell Value < 0, Change Value to 0
 

Solution:

Sub LessThanZero()
Dim cell As Range
'Change the worksheet and column values to suit your needs.
For Each cell In Range("Sheet1!A:A")
If cell.Value < 0 Then
cell.Value = 0
End If
Next
End Sub


--
tcgaines
------------------------------------------------------------------------
tcgaines's Profile: http://www.excelforum.com/member.php...o&userid=29608
View this thread: http://www.excelforum.com/showthread...hreadid=496840


Govind

If Cell Value < 0, Change Value to 0
 
Hi,

You can write an IF formula like

=IF(A1<0,0,A1)

and copy it across the range.

Regards

Govind.

tcgaines wrote:

The subject says it all. I want to search a range for cell values that
are < 0 and if they are, change the value to 0. how do i do that?

thx




All times are GMT +1. The time now is 05:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com