- 帖子
- 835
- 主題
- 6
- 精華
- 0
- 積分
- 915
- 點名
- 0
- 作業系統
- Win 10,7
- 軟體版本
- 2019,2013,2003
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2010-5-3
- 最後登錄
- 2025-7-5
|
我覺得這個 Case 不使用 Dictionary 反而可能會更快呢, 程式如下 :
Sub Ex()
Dim i%, j%, iSou%, iRes%, Text$
Dim rC As Range
Sheets("Result").Range("A2:G65536").Clear
iRes = 2
With Sheets("Date")
iSou = .Range("B65536").End(xlUp).Row
For j = 2 To iSou
' 這邊原想要套用 Join 方法但搭配 Cells 一直都說 "執行錯誤", 所以只能暫時先這樣用囉.
Text = .Cells(j, 2) & "-" & .Cells(j, 3) & "-" & .Cells(j, 4) & "-" & .Cells(j, 5) & "-" & .Cells(j, 6)
With Sheets("Result")
Set rC = .Range(.Cells(2, 7), .Cells(iRes, 7)).Find(Text, LookIn:=xlValues)
If Not rC Is Nothing Then
i = rC.Row
.Cells(i, 6) = .Cells(i, 6) + 1
Else
.Cells(iRes, 7) = Text
.Cells(iRes, "A").Resize(, 5) = Split(Text, "-")
.Cells(iRes, 6) = 1
iRes = iRes + 1
End If
End With
Next j
End With
Sheets("Result").Range("G2:G65536").Clear
End Sub |
|