Hi,
What is wrong with the following formula?
=SearchNReplace1("[a-zA-Z0-9_]*\s[a-zA-Z0-9_]*\s[a-zA-Z0-9_]*[…]$","[...]$","\s",A9)
I am trying to do the following: If cell A9 contains (word followed by a space followed by a word followed by a space followed by a word followed by ...), replace ... with nothing or a whitespace
Here is the SearchNReplace1 function, however I believe the logic in the function is correct.
<CODE>Public Function SearchNReplace1(Pattern1 As String, _
Pattern2 As String, Replacestring As String, _
TestString As String)
Dim reg As New RegExp
reg.IgnoreCase = True
reg.MultiLine = False
reg.Pattern = Pattern1
If reg.Test(TestString) Then
reg.Pattern = Pattern2
SearchNReplace1 = reg.Replace(TestString, ReplaceString)
Else
SearchNReplace1 = TestString
End If
End Function
</CODE>
Thanks in advance!
What is wrong with the following formula?
=SearchNReplace1("[a-zA-Z0-9_]*\s[a-zA-Z0-9_]*\s[a-zA-Z0-9_]*[…]$","[...]$","\s",A9)
I am trying to do the following: If cell A9 contains (word followed by a space followed by a word followed by a space followed by a word followed by ...), replace ... with nothing or a whitespace
Here is the SearchNReplace1 function, however I believe the logic in the function is correct.
<CODE>Public Function SearchNReplace1(Pattern1 As String, _
Pattern2 As String, Replacestring As String, _
TestString As String)
Dim reg As New RegExp
reg.IgnoreCase = True
reg.MultiLine = False
reg.Pattern = Pattern1
If reg.Test(TestString) Then
reg.Pattern = Pattern2
SearchNReplace1 = reg.Replace(TestString, ReplaceString)
Else
SearchNReplace1 = TestString
End If
End Function
</CODE>
Thanks in advance!