View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Macro to replace "0" (Zero) with Hyphen in all Cells

Hi KnightRider,

Try:

'=============
Public Sub Tester2()
Dim rng As Range

Set rng = Range("A1:A30") '<<==== CHANGE
rng.Replace What:="0", _
Replacement:="-", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows
End Sub
'<<=============


---
Regards,
Norman



"KnightRiderAW" wrote in message
...
I need a macro that will search each cell and determine if it has a zero
value in it. If it does, it will replace the zero (or in the case of my
data, 0.00), with a hyphen "-".

Here is an example:

Before

A B C D
1 Item1 $5.00 EACH 2.35
2 Item2 $0.75 EACH 0.50
3 Item3 $0.00 0.00
4 Item4 $2.50 CASE 0.00

After

A B C D
1 Item1 $5.00 EACH 2.35
2 Item2 $0.75 EACH 0.50
3 Item3 - -
4 Item4 $2.50 CASE -

As you can see, if a cell is blank and has no data in it, I don't want a
hyphen in there. Only where the cell has 0.00 in it. Thanks for the
help!