Find the all rows number of the each pattern

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Using Excel 2000</SPAN></SPAN>

Hi,</SPAN></SPAN>

I want to find the all rows number of the each pattern</SPAN></SPAN>

Below example shows the row numbers only for first 2 patterns, it is difficult to find manually.</SPAN></SPAN>

Please need VBA help?</SPAN></SPAN>

Result</SPAN></SPAN> data example</SPAN></SPAN></SPAN>


Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAI
1Cycle1
2CycleX
3Cycle2
4Next Delay-->
5EM1|1|11|1|X1|1|21|X|11|X|X1|X|21|2|11|2|X1|2|2X|1|1X|1|XX|1|2X|X|1X|X|XX|X|2X|2|1X|2|XX|2|22|1|12|1|X2|1|22|X|12|X|X2|X|22|2|12|2|X2|2|2
6X|1|21626
71|X|22032
81|X|12257
91|X|12359
10X|1|X2468
11X|X|X4872
122|X|150
13X|1|X51
141|X|X52
15X|2|X55
161|1|161
171|2|163
181|X|X64
191|X|X71
201|1|1
21X|1|2
221|1|1
231|1|1
241|1|1
251|2|2
261|1|X
27X|X|X
28X|2|1
291|X|2
302|1|X
311|X|1
321|1|X
332|1|X
34X|1|1
351|2|1
36X|1|1
372|X|1
381|X|2
39X|1|X
401|X|X
411|X|1
421|2|1
43X|1|1
442|X|X
45X|2|1
461|X|X
47X|X|1
481|1|1
49X|X|1
501|1|1
511|1|1
521|1|1
532|X|1
541|X|X
551|1|1
56X|1|1
571|1|X
581|2|2
591|1|X
601|2|2
611|1|1
622|1|1
631|1|1
641|1|1
651|2|1
661|2|2
671|1|1
681|1|X
691|X|1
70X|1|1
711|1|1
721|1|X
731|X|X
74X|X|1
751|1|2
76
77
Sheet1


Thank you in advance</SPAN></SPAN>

Regards,</SPAN>
Kishan</SPAN>
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try this:-

Code:
[COLOR="Navy"]Sub[/COLOR] MG01Sep27
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Sp [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("C6"), Range("C" & Rows.Count).End(xlUp))
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] Not .exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
        .Add Dn.Value, Dn.Row
    [COLOR="Navy"]Else[/COLOR]
        .Item(Dn.Value) = .Item(Dn.Value) & ", " & Dn.Row
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]

[COLOR="Navy"]Set[/COLOR] Rng = Range("E5", Cells(5, Columns.Count).End(xlToLeft))
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        [COLOR="Navy"]If[/COLOR] .exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
            Sp = Split(.Item(Dn.Value), ", ")
            Dn.Offset(1).Resize(UBound(Sp) + 1).Value = Application.Transpose(Sp)
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try this:-

Code:
[COLOR=navy]Sub[/COLOR] MG01Sep27
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range, n [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] Sp [COLOR=navy]As[/COLOR] Variant
[COLOR=navy]Set[/COLOR] Rng = Range(Range("C6"), Range("C" & Rows.Count).End(xlUp))
[COLOR=navy]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
    [COLOR=navy]If[/COLOR] Not .exists(Dn.Value) [COLOR=navy]Then[/COLOR]
        .Add Dn.Value, Dn.Row
    [COLOR=navy]Else[/COLOR]
        .Item(Dn.Value) = .Item(Dn.Value) & ", " & Dn.Row
    [COLOR=navy]End[/COLOR] If
[COLOR=navy]Next[/COLOR]

[COLOR=navy]Set[/COLOR] Rng = Range("E5", Cells(5, Columns.Count).End(xlToLeft))
    [COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
        [COLOR=navy]If[/COLOR] .exists(Dn.Value) [COLOR=navy]Then[/COLOR]
            Sp = Split(.Item(Dn.Value), ", ")
            Dn.Offset(1).Resize(UBound(Sp) + 1).Value = Application.Transpose(Sp)
        [COLOR=navy]End[/COLOR] If
    [COLOR=navy]Next[/COLOR] Dn
[COLOR=navy]End[/COLOR] [COLOR=navy]With[/COLOR]
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
Hi Mick, it is just amazing, perfect results!!</SPAN></SPAN>

Thank you for quick response, solved totally
</SPAN></SPAN>

Have a great weekend
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Kishan :)
</SPAN></SPAN>
 
Upvote 0

Forum statistics

Threads
1,216,411
Messages
6,130,440
Members
449,581
Latest member
econtent2

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