Replace in Excel 97

  • Thread starter Thread starter pcw
  • Start date Start date
P

pcw

I used the Replace function in my code while developing in
Excel XP. However, it comes back with an error when I try
to run it in Excel 97.

Is there an equivalent to the Replace function in Excel 97?
Note: this is not being used in the formula bar.
 
No, Replace came in in XL2000.

You can write your own though

Function Replace97(Source As String, Find As String, Replace As String)
Dim iPos As Long
Dim sTemp As String

sTemp = Source
Do
iPos = InStr(sTemp, Find)
sTemp = Left(sTemp, iPos - 1) & Replace & Right(sTemp, Len(sTemp) -
Len(Find) - iPos + 1)
Loop Until InStr(sTemp, Find) = 0
Replace97 = sTemp
End Function


or you could use the worksheet substitute function

Debug.Print Application.Substitute("Bob", "o", "a")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top