- 帖子
- 1018
- 主題
- 15
- 精華
- 0
- 積分
- 1058
- 點名
- 0
- 作業系統
- win7 32bit
- 軟體版本
- Office 2016 64-bit
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 桃園
- 註冊時間
- 2012-5-9
- 最後登錄
- 2022-9-28
|
2#
發表於 2014-6-6 17:03
| 只看該作者
回復 1# ii31sakura - Sub Test()
- Dim r As Long, sCond As String
- Dim d, sSN As String, sType As String, max, maxType
-
- Set d = CreateObject("scripting.dictionary")
-
- With Sheets("Data")
- sCond = .[G1].Text
- r = .Cells(.Rows.count, "A").End(xlUp).Row - 1
- If r <= 0 Then Exit Sub
- For Each s In .[A2].Resize(r).Value
- sSN = Split(s, "-")(0)
- sType = Split(s, "-")(1)
- If sSN = sCond Then
- d(s) = d(s) + 1
- If d(s) > max Then max = d(s): maxType = sType
- End If
- Next
-
- .[J1].Value = maxType
- .[J2].Value = max
- End With
-
- End Sub
複製代碼 |
|