|
Option Explicit
Sub TEST2()
Dim ar, br, i&, j&, r&, k&, iPosRow&
Application.ScreenUpdating = False
r = Cells(Rows.Count, "A").End(xlUp).Row
ar = Range("A1:G1" & r).Value
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
r = 0
For i = 1 To UBound(ar) Step 3
If ar(i, 3) = ar(i + 1, 3) Then
If (ar(i, 6) = ar(i + 1, 6)) And ar(i, 7) = "A" And ar(i + 1, 7) = "B" Then
r = r + 1
iPosRow = (r - 1) * 3 + 1
For k = 0 To 1
For j = 1 To UBound(ar, 2)
br(iPosRow + k, j) = ar(i + k, j)
Next j
Next k
End If
End If
Next i
[Q1].Resize(iPosRow + 1, UBound(br, 2)) = br
Application.ScreenUpdating = True
Beep
End Sub
|
|