While I have seen many replace substring functions posted here and elsewhere I
am amazed out how complex most of them are. here is a very simple function that
performs extremely well.
Keeping it Simple is the Key to quality applications!
Function ReplaceSubString(SourceS As String, SearchS As String, ReplaceS As
String) As String
While Instr(SourceS, SearchS) > 0
SourceS = Left$(SourceS, Instr(SourceS, SearchS) - 1) + ReplaceS +
Right$(SourceS, Len(SourceS) - Instr(SourceS, SearchS) - Len(SearchS) + 1)
ReplaceSubstring = SourceS
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.