Hi,
Try to do it this way
For i = 1 To Len(Word)
If UCase(Mid(Word, i, OLength)) = UCase(Oldstring) Then
ReplaceChars = Mid(Word, 1, i - 1) & NewString & Mid(Word, i + OLength)
Exit For
End If
Next
If Len(ReplaceChars) = 0 Then
ReplaceChars = Word
End If
End Function
Sub CallFunction()
Dim Cell As Range
For Each Cell In Selection
Cell.Value = ReplaceChars(Cell.Value, "old", "new")
Next
End Sub
-vemaju
|