- 帖子
- 2035
- 主題
- 24
- 精華
- 0
- 積分
- 2031
- 點名
- 0
- 作業系統
- Win7
- 軟體版本
- Office2010
- 閱讀權限
- 100
- 性別
- 男
- 註冊時間
- 2012-3-22
- 最後登錄
- 2024-2-1
|
24#
發表於 2013-7-25 19:40
| 只看該作者
回復 20# GBKEE
回復 23# jackyliu - Option Explicit
- Sub ex()
- Dim D As Object, E As Variant, cts As Integer
-
- Set D = CreateObject("Scripting.dictionary") ' 字典物件
-
- For Each E In Sheet1.Range("A1").CurrentRegion.Rows ' 物件: A1 所延伸範圍的列
- If D.exists(E.Cells(1, 1) & E.Cells(1, 2) & E.Cells(1, 3) & E.Cells(1, 5)) = False Then _
- D(E.Cells(1, 1) & E.Cells(1, 2) & E.Cells(1, 3) & E.Cells(1, 5)) = E.Value
- Next
-
- With Sheet2
- .Cells.Clear
- cts = 1
- For Each E In D.KEYS
- .Cells(cts, "A").Resize(1, UBound(D(E), 2)).Value = D(E) ' 讀取字典物件的 ITEM (陣列)
- cts = cts + 1
- Next
- End With
- Set D = Nothing
- End Sub
複製代碼 加入了過濾判斷,If D.exists(E.Cells(1, 1) & E.Cells(1, 2) & E.Cells(1, 3) & E.Cells(1, 5)) = False Then ....,
jackyliu 請再試看看! |
|