Hi,
I am using the following code to identify and count patterns in Excel. I have patterns such as 1,3,2 in rows. Column A contains the entire data set that from which the patterns must be identified and counted and in Column C I have (c1 = serach pattern C2=1,C3=3,C4=2). This code only worked for few rows. Is there any other way of counting the patterns.
Sub test() </pre>
With CreateObject("VBScript.RegExp") </pre>
.Global = True </pre>
.Pattern = _ </pre>
"\b" & Join(Application.Transpose(Range("c2", Range("c" & Rows.Count).End(xlUp)).Value)) & "\b" </pre>
MsgBox .Execute(Join(Application.Transpose(Range("a1", Range("a" & Rows.Count).End(xlUp)).Value))).Count </pre>
End With </pre>
End Sub
</pre>
I am using the following code to identify and count patterns in Excel. I have patterns such as 1,3,2 in rows. Column A contains the entire data set that from which the patterns must be identified and counted and in Column C I have (c1 = serach pattern C2=1,C3=3,C4=2). This code only worked for few rows. Is there any other way of counting the patterns.
Sub test() </pre>
With CreateObject("VBScript.RegExp") </pre>
.Global = True </pre>
.Pattern = _ </pre>
"\b" & Join(Application.Transpose(Range("c2", Range("c" & Rows.Count).End(xlUp)).Value)) & "\b" </pre>
MsgBox .Execute(Join(Application.Transpose(Range("a1", Range("a" & Rows.Count).End(xlUp)).Value))).Count </pre>
End With </pre>
End Sub
</pre>