- Sub lqxs()
- Dim Arr, i&, r%, Arr1(), n&, m&, nn&, ks, js, j&
- Sheet2.Activate
- nn = 1
- [a2:j5000].ClearContents
- Arr = Sheet1.[a1].CurrentRegion
- For i = 2 To UBound(Arr)
- If Arr(i, 2) <> Arr(i - 1, 2) Then
- r = r + 1
- ReDim Preserve Arr1(1 To r)
- Arr1(r) = i
- End If
- Next
- For i = 1 To r
- m = 0: n = 0
- If i <> r Then
- js = Arr1(i + 1) - 1
- Else
- js = UBound(Arr)
- End If
- ks = Arr1(i)
- For y = 6 To 7
- For j = js - 1 To ks Step -1
- If Arr(j, y) > Arr(j + 1, y) Then
- If y = 6 Then n = j Else m = j
- End If
- Next
- Next
- If n = m Then
- nn = nn + 1
- Cells(nn, 1).Resize(1, UBound(Arr, 2)) = Application.Index(Arr, n, 0)
- ElseIf n < m Then
- If Arr(n, 6) = Arr(n, 7) Then
- nn = nn + 1
- Cells(nn, 1).Resize(1, UBound(Arr, 2)) = Application.Index(Arr, n, 0)
- End If
- Else
- If Arr(n, 6) = Arr(m, 6) Then
- nn = nn + 1
- Cells(nn, 1).Resize(1, UBound(Arr, 2)) = Application.Index(Arr, m, 0)
- End If
- End If
- Next
- End Sub
复制代码 |