View Single Post
  #23 (permalink)  
Old November 22nd, 2005, 02:04 AM
vemaju vemaju is offline
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote