ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ½Ð°Ý«e½úÃö©óVBA ¤¤¦r¦ê²Î­p°ÝÃD

¦^´_ 1# ii31sakura
  1. Sub Test()
  2.   Dim r As Long, sCond As String
  3.   Dim d, sSN As String, sType As String, max, maxType
  4.   
  5.   Set d = CreateObject("scripting.dictionary")
  6.   
  7.   With Sheets("Data")
  8.     sCond = .[G1].Text
  9.     r = .Cells(.Rows.count, "A").End(xlUp).Row - 1
  10.     If r <= 0 Then Exit Sub
  11.     For Each s In .[A2].Resize(r).Value
  12.       sSN = Split(s, "-")(0)
  13.       sType = Split(s, "-")(1)
  14.       If sSN = sCond Then
  15.         d(s) = d(s) + 1
  16.         If d(s) > max Then max = d(s): maxType = sType
  17.       End If
  18.     Next
  19.    
  20.     .[J1].Value = maxType
  21.     .[J2].Value = max
  22.   End With
  23.   
  24. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ­ì½Ì§O¤H´N¬Oµ½«Ý¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD