Re: Identify and number Patterns
I have superseded the attachment in Post #180 with the following link.
https://www.mediafire.com/?9oi160wvn3ug766 (8.14 mb)
If you don't want to download, here are the macros, changes commented in upper case.
Code
Option Explicit
Sub update()
Application.ScreenUpdating = False
Range("H3").FormulaR1C1 = _
"=RC[-6]&RC[-5]&RC[-4]&RC[-3]&R[1]C[-6]&R[1]C[-5]&R[1]C[-4]&R[1]C[-3]&R[2]C[-6]&R[2]C[-5]&R[2]C[-4]&R[2]C[-3]&R[3]C[-6]&R[3]C[-5]&R[3]C[-4]&R[3]C[-3]&R[4]C[-6]&R[4]C[-5]&R[4]C[-4]&R[4]C[-3]&R[5]C[-6]&R[5]C[-5]&R[5]C[-4]&R[5]C[-3]&R[6]C[-6]&R[6]C[-5]&R[6]C[-4]&R[6]C[-3]&R[7]C[-6]&R[7]C[-5]&R[7]C[-4]&R[7]C[-3]"
With Range("H12:H" & Range("A" & Rows.Count).End(xlUp).Row)
.NumberFormat = "0"
.FormulaR1C1 = _
"=RC[-6]&RC[-5]&RC[-4]&RC[-3]&R[1]C[-6]&R[1]C[-5]&R[1]C[-4]&R[1]C[-3]&R[2]C[-6]&R[2]C[-5]&R[2]C[-4]&R[2]C[-3]&R[3]C[-6]&R[3]C[-5]&R[3]C[-4]&R[3]C[-3]&R[4]C[-6]&R[4]C[-5]&R[4]C[-4]&R[4]C[-3]&R[5]C[-6]&R[5]C[-5]&R[5]C[-4]&R[5]C[-3]&R[6]C[-6]&R[6]C[-5]&R[6]C[-4]&R[6]C[-3]&R[7]C[-6]&R[7]C[-5]&R[7]C[-4]&R[7]C[-3]"
.NumberFormat = "@"
.Value = .Value
End With
Application.ScreenUpdating = True
End Sub
Sub PatternSearch()
Dim rng As Range, x As Long, y As Long, Cell
If Range("A" & Rows.Count).End(xlUp).Row <> Range("H" & Rows.Count).End(xlUp).Row Then
Call update
End If 'HAD TO MOVE THIS TO TOP OF PROCEDURE
If Application.CountIf(Range("H12:H" & Range("H" & Rows.Count).End(xlUp).Row), [H3]) = 0 Then
MsgBox "No matching patterns"
Exit Sub
End If
Application.ScreenUpdating = False
Sheets("Sheet2").Columns("L:Q").Clear
Set rng = Range("H12:H" & Range("A" & Rows.Count).End(xlUp).Row)
rng.Replace Range("H3").Value, "", , MatchCase:=True
For Each Cell In rng.SpecialCells(4)
x = Application.Max(12, Cell.Row - 10) 'PUT THIS BACK
y = Cell.Row + 17
Sheets("Sheet1").Range("A" & x & ":F" & y).Copy Sheets("Sheet2").Range("L" & Sheets("Sheet2").Rows.Count).End(xlUp)(3)
Next
rng.SpecialCells(4) = Range("H3").Value
Application.ScreenUpdating = True
Sheets("Sheet2").Activate
End Sub
Display More
snb was on the verge of a much better solution, but like Kjbox, I was getting debug in same place.