The Replace Holders Function

This function replaces the placeholders in a string with values provided to it:

Function ReplaceHolders(ByVal sString As String, ParamArray avReplace()) As String Dim i As Integer

'Work backwards, so we don't replace %10 with our %1 text For i = UBound(avReplace) To LBound(avReplace) Step -1 sString = Application.Substitute(sString, "%" & i, _ avReplace(i - LBound(avReplace)))

Next

ReplaceHolders = sString End Function sString is the text to replace the placeholders in, and avReplace is a list of items to replace the placeholders.

0 0

Post a comment