I am using Regex to find and replace but it is failing on a data type mismatch.
The code is:-
[vba]
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.Pattern = "\s\?.+\?\s"
For Each cl In Columns(G_SupplierDescriptionColumn).SpecialCells(2)
For Each m In .Execute(cl)
cl.Replace m, Replace(m, "?", Chr(34))
Next
Next
End With
[/vba]
The code is failing on the line:-
[vba]cl.Replace m, Replace(m, "?", Chr(34))[/vba]
The intended behaviour should be that for a selected column of my worksheet values in each cell are parsed for patterns such as:-
?The cow jump over the moon?
and replaces such occurences with:-
"The cow jump over the moon?"
What is causing the data type error? I am using pretty much the same routine to find/replace other string patterns in the same column with no such problems.