|
楼主 |
发表于 2021-3-22 00:12
|
显示全部楼层
我优化了一下程序,可以表现出来了
Sub shishi()
Worksheets(1).[l2:T65536].ClearContents
Dim HIGHMAX, HIGHMIN, DEEPMAX, DEEPMIN
HIGHMAX = Range("K15")
HIGHMIN = Range("K16")
DEEPMAX = Range("K18")
DEEPMIN = Range("K19")
Dim I, J, K, L
Dim ARR, BRR, CRR, drr
ARR = Range("a1:c" & Range("a65536").End(xlUp).Row)
BRR = Range("e1:f" & Range("e65536").End(xlUp).Row)
CRR = Range("h1:i" & Range("h65536").End(xlUp).Row)
For I = 2 To UBound(ARR)
For J = 2 To UBound(BRR)
For K = 2 To UBound(CRR)
If BRR(J, 2) - ARR(I, 2) >= HIGHMIN And BRR(J, 2) - ARR(I, 2) <= HIGHMAX And CRR(K, 2) - ARR(I, 3) >= DEEPMIN And CRR(K, 2) - ARR(I, 3) <= DEEPMAX Then
Range("a" & I & ":" & "c" & I).Copy Range("l" & Range("l65536").End(xlUp).Row + 1)
Range("e" & J & ":" & "f" & J).Copy Range("o" & Range("l65536").End(xlUp).Row)
Range("h" & K & ":" & "i" & K).Copy Range("q" & Range("l65536").End(xlUp).Row)
Range("S" & Range("l65536").End(xlUp).Row) = Range("P" & Range("l65536").End(xlUp).Row) - Range("M" & Range("l65536").End(xlUp).Row)
Range("T" & Range("l65536").End(xlUp).Row) = Range("R" & Range("l65536").End(xlUp).Row) - Range("N" & Range("l65536").End(xlUp).Row)
End If
Next
Next
Next
End Sub
- Sub shishi()
- Worksheets(1).[l2:T65536].ClearContents
- Dim HIGHMAX, HIGHMIN, DEEPMAX, DEEPMIN
- HIGHMAX = Range("K15")
- HIGHMIN = Range("K16")
- DEEPMAX = Range("K18")
- DEEPMIN = Range("K19")
- Dim I, J, K, L
- Dim ARR, BRR, CRR, drr
- ARR = Range("a1:c" & Range("a65536").End(xlUp).Row)
- BRR = Range("e1:f" & Range("e65536").End(xlUp).Row)
- CRR = Range("h1:i" & Range("h65536").End(xlUp).Row)
- For I = 2 To UBound(ARR)
- For J = 2 To UBound(BRR)
- For K = 2 To UBound(CRR)
- If BRR(J, 2) - ARR(I, 2) >= HIGHMIN And BRR(J, 2) - ARR(I, 2) <= HIGHMAX And CRR(K, 2) - ARR(I, 3) >= DEEPMIN And CRR(K, 2) - ARR(I, 3) <= DEEPMAX Then
- Range("a" & I & ":" & "c" & I).Copy Range("l" & Range("l65536").End(xlUp).Row + 1)
- Range("e" & J & ":" & "f" & J).Copy Range("o" & Range("l65536").End(xlUp).Row)
- Range("h" & K & ":" & "i" & K).Copy Range("q" & Range("l65536").End(xlUp).Row)
- Range("S" & Range("l65536").End(xlUp).Row) = Range("P" & Range("l65536").End(xlUp).Row) - Range("M" & Range("l65536").End(xlUp).Row)
- Range("T" & Range("l65536").End(xlUp).Row) = Range("R" & Range("l65536").End(xlUp).Row) - Range("N" & Range("l65536").End(xlUp).Row)
- End If
- Next
- Next
- Next
- End Sub
复制代码 |
|