|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
其实,弄清楚要求,题目还算简单:
Sub zz()
Dim ar, br, mb, wb As Workbook
mb = Sheet1.[a1].CurrentRegion
Application.ScreenUpdating = False
Set wb = Workbooks.Open(ThisWorkbook.Path & "\2.xlsx")
With wb
lr = .Sheets(2).Range("A1048576").End(3).Row
ar = .Sheets(2).Range("A1:I" & lr)
.Close False
End With
For w = 2 To UBound(mb)
ReDim br(1 To 50, 1 To 2)
br(1, 1) = mb(w, 1): m = 1
For i = 1 To UBound(ar)
If ar(i, 6) = mb(w, 1) Then
k = i: m = m + 1
br(m, 2) = ar(i, 9)
For x = k To 1 Step -1
If ar(x, 3) = 0 Then
br(m, 1) = ar(x, 6)
Exit For
End If
Next
End If
Next
Sheet2.Cells(2 + n, 1).Resize(m, 2) = br
n = n + m + 1
Next
Application.ScreenUpdating = True
End Sub
|
|