Why write when you can Copy-n-Paste? ;)
From [link|http://www.tek-tips.com/gfaqs.cfm/pid/705/fid/4342|http://www.tek-tips..../pid/705/fid/4342]
\n'------------------------------------------------------------------------------------\nPublic Function Replace(Expression As String, _\n Find As String, ByVal ReplaceWith As String, _\n Optional Start As Long = 1, Optional Count As Long = -1, _\n Optional Compare As Integer = vbBinaryCompare) As String\n'------------------------------------------------------------------------------------\n' Purpose: Replaces occurrences of a substring within a string with a specified\n' repacement string.\n' Accepts: 1. String containing substrings to be replaced\n' 2. Value of the substring to be found\n' 3. Replacement value to substitute for the substring\n' 4. Optional starting position for the search, default=1 (start of string)\n' 5. Optional maximum number of occurrences to replace, default=-1 (all\n' occurences)\n' 6. Optional text comparison method (default: binary compare)\n' Returns: The part of the string starting at the Start position, with substitutions\n' made. Returns an empty string if Start > Len(Expression).\nDim str As String\nDim i As Long\nDim lngFindLen As Long\nDim c As Long\n\nIf Start < 1 Then Err.Raise 5\nIf Count < -1 Then Err.Raise 5\nIf Compare < 0 Or Compare >= 40 Then Err.Raise 5\nstr = Mid$(Expression, Start)\nlngFindLen = Len(Find)\nIf lngFindLen > 0 Then\nc = Count\ni = 1\nDo While c <> 0\ni = InStr(i, str, Find, Compare)\nIf i = 0 Then Exit Do\nIf lngFindLen = Len(ReplaceWith) Then\nMid$(str, i, lngFindLen) = ReplaceWith\nElse\nstr = Left$(str, i - 1) & ReplaceWith & Mid$(str, i + lngFindLen)\nEnd If\ni = i + Len(ReplaceWith)\nIf c > 0 Then c = c - 1\nLoop\nEnd If\nReplace = str\nEnd Function\n