- 帖子
- 234
- 主題
- 19
- 精華
- 0
- 積分
- 276
- 點名
- 0
- 作業系統
- Windows XP
- 軟體版本
- office 2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2013-1-7
- 最後登錄
- 2021-10-7
|
已解決,謝謝大家
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 |
|