ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to replace negative numbers by 0 (https://www.excelbanter.com/excel-programming/275774-re-macro-replace-negative-numbers-0-a.html)

William[_2_]

Macro to replace negative numbers by 0
 
Hi Bill
Try....

Sub NoNegatives()
With ActiveSheet.Cells
Dim r As Range
..SpecialCells(xlCellTypeLastCell).Offset(1, 0) = -2
Set r = .SpecialCells(xlCellTypeConstants, xlNumbers)
r.Replace What:="-*", Replacement:=0, LookAt:=xlPart
..SpecialCells(xlCellTypeLastCell).ClearContents
End With
End Sub

--
XL2002
Regards

William


"Bill" wrote in message
...
| Hello
|
| May I please ask for your help? I have just completed an
| extensive Google Groups search, but I couldn't find any
| posts that dealt with this problem.
|
| I have many large documents. I need to replace all
| negative numbers found in these documents by zeros [0].
| If these negative numbers were all the same number, I
| would have done "find/replace", but these negative numbers
| are all different...
|
| Is it possible to write a macro that could be run to
| replace all negative numbers [in the active work sheet] by
| 0's?
|
| I would be very grateful for any help and all suggestions.
|
| Sincerely
|
|
| Bill




All times are GMT +1. The time now is 08:30 AM.

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