Option Explicit
Sub test()
Dim brr, i, j, n, arr
brr = [b15].CurrentRegion
brr(4, 4) = brr(4, 2): brr(6, 4) = brr(6, 2): brr(8, 4) = brr(8, 2)
arr = [a1].CurrentRegion: n = 1
For i = 2 To UBound(arr, 1)
For j = 2 To UBound(arr, 2)
If Len(brr(j + 1, 2)) Then
If brr(j + 1, 2) > arr(i, j) Or brr(j + 1, 4) < arr(i, j) Then Exit For
End If
Next
If j = UBound(arr, 2) + 1 Then
n = n + 1
For j = 1 To UBound(arr, 2): arr(n, j) = arr(i, j): Next
End If
Next
With [i1]
.Resize(Rows.Count, UBound(arr, 2)).ClearContents
.Resize(n, UBound(arr, 2)) = arr
End With
End Sub |