Identify and Count Patterns in Data in Excel

Nina23

New Member
Joined
Jun 5, 2013
Messages
3
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>
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,226,693
Messages
6,192,471
Members
453,726
Latest member
JoeH57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top