- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 26# jackyliu
再試試看- Option Explicit
- Sub Ex()
- Dim D As Object, E, i As Integer
- Set D = CreateObject("Scripting.dictionary") '字典物件
- i = 1
- With Sheet1
- Do While .Cells(i, "A") <> ""
- E = .Cells(i, "A") & .Cells(1, "B") & .Cells(1, "C") & .Cells(1, "E")
- If D.exists(E) = False Then
- D(E) = .Cells(i, "A").Resize(1, 6).Value
- End If
- i = i + 1
- Loop
- End With
- i = 1
- With Sheet2
- .Cells.Clear
- For Each E In D.KEYS
- .Cells(i, "A").Resize(1, UBound(D(E), 2)) = D(E) '讀取字典物件的ITEM(陣列)
- i = i + 1
- Next
- End With
- End Sub
複製代碼 |
|