View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default replace() funciton with multiple tests....

Hi,

Am Tue, 29 Nov 2016 01:08:10 +0100 schrieb Claus Busch:

tempstring = Replace(Replace(string, "purge_", "cor010_wcout"), "dealdrop_", "cor010_wcout")

or you can do it with an array:

varRep = Array("purge_", "dealdrop_")
For i = LBound(varRep) To UBound(varRep)
tempstring = Replace(string, varRep(i), "cor010_wcout")
Next


or another suggestion with Regexp:

Set re = CreateObject("vbscript.Regexp")
ptrn = "purge_|dealdrop_"
re.Pattern = ptrn
re.IgnoreCase = False
re.Global = True

tempstr = re.Replace(string, "cor010_wcout")


Regards
Claus B.
--
Windows10
Office 2016