Showing posts with label Replace. Show all posts
Showing posts with label Replace. Show all posts

Sep 2, 2008

How Use Replace Function in Excel 97 (UDF Replace97)

Function Replace97(OriStr As Variant, _
               Str1 As String,  Str2 As String, _
               Optional Pos As  Double = 1)
Dim i9 As Double
Dim Fn As WorksheetFunction
Set Fn = Application.WorksheetFunction
If Pos = 1 Then
    Replace97 = Fn.Substitute(OriStr, Str1, Str2)
Else
Replace97 = OriStr
    For i9 = Pos To Len(OriStr)
    Replace97 = Fn.Substitute(Replace97, Str1, Str2, i9)
    Next
End If
End Function
Locations of visitors to this page