|
- Sub 按钮1_Click()
- Dim arr1()
- Dim brr, arr, r%, r1%, n%, i%, ii%
- timesr = Timer
- r = Cells(Rows.Count, "G").End(xlUp).Row
- r1 = Sheets("明细表").Cells(Rows.Count, "B").End(xlUp).Row
- arr = Application.Transpose(Array(Application.Transpose(Range("G3:G" & r)), Application.Transpose(Range("M3:M" & r)), Application.Transpose(Range("X3:X" & r))))
- With Sheets("明细表")
- brr = Application.Transpose(Array(Application.Transpose(.Range("B2:B" & r1)), Application.Transpose(.Range("C2:C" & r1)), Application.Transpose(.Range("F2:F" & r1)), Application.Transpose(.Range("H2:H" & r1)), Application.Transpose(.Range("R2:R" & r1))))
- End With
- For i = 1 To UBound(arr)
- n = n + 1
- ReDim Preserve arr1(1 To n)
- For ii = 1 To UBound(brr)
- If arr(i, 1) = brr(ii, 3) And arr(i, 2) = brr(ii, 4) And arr(i, 3) >= brr(ii, 1) And arr(i, 3) <= brr(ii, 2) Then
- arr1(n) = brr(ii, 5)
- End If
- Next
- Next
- Range("Y3:Y" & r).ClearContents
- [Y3].Resize(UBound(arr1)) = Application.Transpose(arr1)
- MsgBox UBound(arr1) & "行数据生成完毕" & Chr(10) & "用时:" & Format(Timer - timesr, "0.0") & "秒"
- End Sub
复制代码 |
|