Help - Replace Values Less Than Zero

Delta Star

Board Regular
Joined
Oct 28, 2009
Messages
184
I have a range of cells D64:CD230763. I need to be able to replace any cells less than zero with 0. Can anyone assist?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try

Code:
Sub zero()
Dim c As Range
For Each c In Range("D64:CD230763")
    If c.Value < 0 Then c.Value = 0
Next c
End Sub
 
Upvote 0
Hi

Another option:

- select the cells with the numbers
- use Find/Replace with the option "Match entire cell contents", replace -* with 0
 
Upvote 0
Or another code option
Code:
Sub negtozero()
Range("D64:CD230763").Name = "a"
Range("a") = Evaluate("if(a<0,0,a)")
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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