How to use vba function to expand the substitute function from the replacement of one pattern to several patterns?
The desired result is : Instead of substitute(cell, pattern, replacement, instancenumber), is it possible to define a function like sub2(cell, pat1, replacement 1, pat2, replacement 2, pat3,replacement 3,...)?
Thanks.
You can do this using
ParamArrays
which allow you to pass in as many arguments as you like. From here you interpret the values in the array to perform custom logic:Now calling it, would look something like this: