View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
William[_2_] William[_2_] is offline
external usenet poster
 
Posts: 227
Default 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