已解決,謝謝大家
Sub Ex()
Dim Ay(4), Ary(), C As Range
With Sheets(1)
For Each C In .Range(.[a2], .[a2].End(xlDown))
If .Cells(C.Row, 3) <> .Cells(C.Row, 5) Or .Cells(C.Row, 4) <> .Cells(C.Row, 6) Then
Ay(0) = .Cells(C.Row, 1): Ay(1) = .Cells(C.Row, 2): Ay(2) = .Cells(C.Row, 3): Ay(3) = .Cells(C.Row, 4)
Ay(4) = .Cells(C.Row, 5)
ReDim Preserve Ary(s)
Ary(s) = Ay
Erase Ay: s = s + 1
End If
Next
End With
Sheets(1).Range("m1:q65526").Clear
Sheets(1).[m1].Resize(s, 5) = Application.Transpose(Application.Transpose(Ary))
End Sub作者: Kubi 時間: 2017-9-21 20:29