|
- Sub t1()
- Dim ar, br, cr, i%, j%, k%, irow%
- ar = Worksheets("T1").Range("a1").CurrentRegion
- ReDim br(1 To UBound(ar, 1), 1 To 4)
- With Worksheets("T2")
- For i = 2 To UBound(ar)
- If ar(i, 1) = .Cells(5, 2) Then
- If ar(i, 2) = .Cells(2, 2) Then
- If ar(i, 3) = .Cells(3, 2) Then
- j = j + 1
- br(j, 1) = ar(i, 7): br(j, 2) = ar(i, 6)
- End If
- End If
- ElseIf ar(i, 1) = .Cells(5, 3) Then
- If ar(i, 2) = .Cells(2, 2) Then
- If ar(i, 3) = .Cells(3, 2) Then
- j = j + 1
- br(j, 1) = ar(i, 7): br(j, 3) = ar(i, 6)
- End If
- End If
- End If
- Next i
-
- .[a6].Resize(UBound(br, 1), 4) = br
- irow = .[a65536].End(xlUp).Row
- For i = 6 To irow
- .Cells(irow + 1, 2) = .Cells(irow + 1, 2) + .Cells(i, 2)
- .Cells(irow + 1, 3) = .Cells(irow + 1, 3) + .Cells(i, 3)
- .Cells(i, 4) = .Cells(i, 4) + .Cells(i, 2) + .Cells(i, 3)
- Next i
- End With
- End Sub
复制代码 |
|