One way:
Public Sub ReplaceSpaces()
Dim rCell As Range
For Each rCell In Selection
With rCell
If InStr(1, Trim(.Text), " ") Then
.NumberFormat = "@"
.Value = Replace(Trim(.Text), " ", "-")
End If
End With
Next rCell
End Sub
If you're using XL97 or MacXL, change Replace(...) to
Application.Substitute(...)
In article ,
"biggyb75" wrote:
I am able to find by the white space but when it replaces with the - it
changes the format. It will not keep it as a text format.
|