|
Sub a()
Set ws1 = Sheets(1)
Set ws2 = Sheets(2)
ws2.Select
For i = 3 To ws1.[b2].End(xlDown).Row
ws2.Range("a2:g2").AutoFilter
ws2.Range("a2:g2").AutoFilter field:=2, Criteria1:=ws1.Cells(i, 2)
ws2.Range("a2:g2").AutoFilter field:=3, Criteria1:=ws1.Cells(i, 3)
ws2.Range("a2:g2").AutoFilter field:=4, Criteria1:=ws1.Cells(i, 4)
ws2.Range("a2:g2").AutoFilter field:=6, Criteria1:=ws1.Cells(i, 6)
If ws2.Cells(99999, 5).End(xlUp) = "数量" Then
Sheets(2).Range("a2:g2").AutoFilter
ws1.Rows(i).Copy ws2.[b99999].End(xlUp).Offset(1, -1)
Else
ws2.[e2].End(xlDown) = ws2.[e2].End(xlDown) + ws1.Cells(i, 5)
End If
Next
ws2.Range("a2:g2").AutoFilter
End Sub
|
|