Along with requested pattern; Bring out 1 next following pattern

Kishan

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

Hi,

I got patterns data in cells C6:C69
In the cells E5:N5 I got patterns, which I want to extract from cells C6:C69 and put them in corresponding column E5:N5 Along with requested pattern; Bringing out 1 next following pattern

For example in column E I want to extract out pattern 1|1|1 from C6:C69 with 1 next following pattern as shown

And in column F I want to extract out pattern 1|1|X from C6:C69 with 1 next following pattern as shown

And so on for the rest.........

Example data...


Book1
ABCDEFGHIJKLMNO
1
2
3
4PattPattPattPattPattPattPattPattPattPatt
5Patt1|1|11|1|X1|1|21|X|11|2|1X|1|12|1|11|X|X1|X|21|2|X
6X|1|1X|1|1
71|1|11|1|11|1|1
81|1|X1|1|X1|1|X
91|X|X1|X|XX|1|11|X|X
101|X|11|1|11|X|11|1|11|X|1
11X|1|11|1|11|1|XX|1|1
121|1|11|1|11|X|1X|1|11|X|X
131|1|11|1|X1|X|11|1|11|2|1
141|1|11|1|XX|1|1
151|1|X1|1|11|X|XX|1|11|X|X
161|X|11|1|11|X|11|1|1X|1|1
17X|1|11|1|11|1|XX|1|1
181|1|11|1|X1|X|2X|1|1
191|1|11|1|X1|1|1
201|1|11|1|11|1|X1|X|2
211|1|X1|1|X1|X|1X|1|1
221|X|X1|X|11|1|1
231|2|11|1|11|1|X1|X|11|2|1
242|1|11|1|21|X|1X|1|12|1|1X|1|12|1|1
251|1|21|1|21|1|11|1|2
261|2|X1|1|11|1|X1|2|X1|X|11|2|11|2|X
271|X|21|1|11|X|1X|1|12|1|1X|1|12|1|11|X|21|X|2
282|1|X1|1|11|1|21|1|11|1|22|1|X
291|X|11|1|21|1|X1|2|11|X|11|2|11|2|X
30X|1|11|X|1X|1|12|1|12|1|11|X|21|X|X
311|1|11|1|11|1|21|1|11|X|1
321|1|X1|1|11|2|11|X|1
331|X|21|1|11|2|X
341|X|11|1|1
351|X|11|1|11|X|1
36X|1|11|1|X
371|1|1
381|1|21|1|1
391|2|11|1|X
402|1|1
411|1|X1|1|1
421|X|11|1|1
43X|1|11|1|1
441|1|11|1|1
451|1|11|1|X
461|1|1
471|1|2
481|2|1
492|1|1
501|1|1
511|1|1
521|1|1
531|1|1
541|1|1
551|1|X
561|X|1
57X|1|1
581|1|1
591|1|X
601|X|1
611|2|X
621|X|X
63X|1|1
641|1|1
651|1|1
661|1|1
671|1|1
681|1|X
691|X|1
70
Sheet4


Thank you in advance

Regards,
Kishan
 
Last edited:

Excel Facts

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

Question in post_3 and explained in post_7

Regards,
Kishan
Hi, I am giving a round my head to change the question to make it easy but can not find any way

May some can help with this as it is requested please.

Thank you in advance

Regards,
Kishan
 
Last edited:
Upvote 0
With the layout from post # 2:

Code:
Sub GetPatterns()

    For c = 5 To Cells(5, "E").End(xlToRight).Column
        Cells(6, c).Resize(Cells(Rows.Count, "C").End(xlUp).Row).ClearContents
        r1 = 6
        For r = 6 To Cells(6, "C").End(xlDown).Row
            If Cells(r, "C") = Cells(5, c) Then
                Cells(r1, c).Resize(2).Value = Cells(r, "C").Resize(2).Value
                r1 = r1 + IIf(Cells(r1 + 1, c) = Cells(5, c), 1, 3)
            End If
        Next r
    Next c
    
End Sub
 
Upvote 0
With the layout from post # 2:

Code:
Sub GetPatterns()

    For c = 5 To Cells(5, "E").End(xlToRight).Column
        Cells(6, c).Resize(Cells(Rows.Count, "C").End(xlUp).Row).ClearContents
        r1 = 6
        For r = 6 To Cells(6, "C").End(xlDown).Row
            If Cells(r, "C") = Cells(5, c) Then
                Cells(r1, c).Resize(2).Value = Cells(r, "C").Resize(2).Value
                r1 = r1 + IIf(Cells(r1 + 1, c) = Cells(5, c), 1, 3)
            End If
        Next r
    Next c
    
End Sub
Wow Erik, thank you so much I was desperate to get solution because I wanted it for final step analysis.

I appreciate your help a lot. Code works perfectly

Have a nice day

Kind Regards,
Kishan :)
 
Upvote 0
With the layout from post # 2:

Hi Erik, you gave a very good code solution, I showed 10 patterns in the example now extended up to 27 and didn't require any change worked like magic.

Thank you once again

Kind Regards,
Kishan
 
Upvote 0

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

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