¦p¦ó³z¹L¼gµ{¦¡¤§¤è¦¡±NabÄæ¦ì¾ã¦X
- ©«¤l
- 3
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 11
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- office2007
- ¾\ŪÅv
- 10
- ©Ê§O
- ¤k
- µù¥U®É¶¡
- 2011-10-29
- ³Ì«áµn¿ý
- 2015-1-22
|
¦p¦ó³z¹L¼gµ{¦¡¤§¤è¦¡±NabÄæ¦ì¾ã¦X
½Ð°Ý¦p¦ó±N(¤@)¤§¸ê®Æ³z¹L¼gµ{¦¡¤§¤è¦¡Âà´«¦¨(¤G)¡AA~D¥Nªí¤½¥q¦WºÙ¬O¤@¼Ëªº¡B1~10¥Nªí¨C¤@Ó¤£¦Pªº³¡ªù¦WºÙ¡C
(¤@) (¤G)
¤½¥q¦WºÙ ³¡ªù¦WºÙ ¤½¥q¦WºÙ ³¡ªù¦WºÙ ³¡ªù¦WºÙ ³¡ªù¦WºÙ ³¡ªù¦WºÙ
A 1 A 1 2 3
A 2 B 4 5
A 3 C 6
B 4 ¡÷ D 7 8 9 10
B 5
C 6
D 7
D 8
D 9
D 10 |
|
|
|
|
|
|
- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-5
|
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim Brr, Crr, Y, i&, T$, M%
'¡ô«Å§iÅܼÆ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OYÅܼƬO ¦r¨å
Brr = Range([B1], [A65536].End(xlUp))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥HA.BÄæÀx¦s®æȱa¤J°}¦C¤¤
ReDim Crr(1 To UBound(Brr), 1 To 100)
'¡ô¥O«Å§iCrrÅܼƬO ¤GºûªÅ°}¦C,Áa¦V½d³ò¦PBrr°}¦C,¾î¦V¯Á¤Þ¸¹1~100
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!±q1¨ìBrr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
T = Brr(i, 1)
'¡ô¥OTÅܼƬO i°j°é²Ä1ÄæBrr°}¦CÈ
If Y(T) = "" Then
'¡ô¦pªGTÅܼƬdY¦r¨åªºitemȬO"" ?
Y(T) = Y.Count
'¡ô¥OY¦r¨åªºTÅܼÆkeyªºitemȬO Y¦r¨åkeyªº¼Æ¶q
Crr(Y(T) \ 2 + 1, 1) = T
'¡ô¥OCrr°}¦C©ñ¤JTÅܼÆ
Y(T & "/C") = 1
'¡ô¥OTÅܼƳs±µ"/C"²Õ¦¨ªº·s¦r¦ê·íkey,item¬O1,¯Ç¤JY¦r¨å¤¤
End If
Y(T & "/C") = Y(T & "/C") + 1
'¡ô¥OY¦r¨å¤¤(TÅܼƳs±µ"/C"²Õ¦¨¦r¦ê)key,¨äitemȲ֥[1
'³o¬On¦bY¦r¨å¤¤°O¿ýTÅܼÆÄ渹
Crr(Y(T) \ 2 + 1, Y(T & "/C")) = Brr(i, 2)
'¡ô¥OCrr°}¦C¦b¾A·í¦ì¸m©ñ¤J i°j°é²Ä2ÄæBrr°}¦CÈ
If Y(T & "/C") > M Then
'¡ô¦pªGY¦r¨å¤¤°O¿ýTÅܼÆÄ渹¤j©óMÅܼÆ
M = Y(T & "/C")
'¡ô´NÅýMÅܼƴ«¸ËÅܼÆÄ渹
Crr(1, M) = Brr(1, 2)
'¡ô¥O¦bCrr°}¦C²Ä1¦CMÄ渹¦ì¸m²K¥[¤@Ó"³¡ªù¦WºÙ"¼ÐÃD
End If
Next
[E1].Resize(Y.Count \ 2 + 1, M) = Crr
'¡ô¥OCrr°}¦Cȱq[E1]¶}©l¼g¤JÀx¦s®æ¤¤
Set Y = Nothing: Erase Brr, Crr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y
|
|
|
|
|
- ©«¤l
- 3
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 11
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- office2007
- ¾\ŪÅv
- 10
- ©Ê§O
- ¤k
- µù¥U®É¶¡
- 2011-10-29
- ³Ì«áµn¿ý
- 2015-1-22
|
¦hÁ¤j¤jªº¸Ô¸Ñ~§Ú¤w¸g¸Õ¦¨¥\ÂP ^.^ |
|
|
|
|
|
|
- ©«¤l
- 1572
- ¥DÃD
- 16
- ºëµØ
- 2
- ¿n¤À
- 1521
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office 2003
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2016-1-13
|
- Sub test()
- Dim d As Object, a, b(100), m%, i%
- Set d = CreateObject("scripting.dictionary")
- a = Range([a1], [b65536].End(3))
- ReDim arr(1 To UBound(a), 1 To UBound(a))
- For i = 1 To UBound(a)
- If Not d.exists(a(i, 1)) Then
- m = m + 1
- d(a(i, 1)) = m
- arr(m, 1) = a(i, 1): arr(m, 2) = a(i, 2): b(m) = 2
- Else
- b(m) = b(m) + 1
- arr(d(a(i, 1)), b(m)) = a(i, 2)
- x = IIf(b(m) > x, b(m), x)
- End If
- Next
- If x > 2 Then
- For i = 3 To x
- arr(1, i) = arr(1, 2)
- Next
- End If
- [d1].Resize(m, x) = arr
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 231
- ¥DÃD
- 55
- ºëµØ
- 0
- ¿n¤À
- 293
- ÂI¦W
- 0
- §@·~¨t²Î
- winxp
- ³nÅ骩¥»
- office2003
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- KEELUNG
- µù¥U®É¶¡
- 2010-7-24
- ³Ì«áµn¿ý
- 2018-8-28
|
¥»©«³Ì«á¥Ñ oobird ©ó 2011-10-29 11:25 ½s¿è
§A¦n¡G
½Ð¸Õ¸Õ¦p¤U¡G- Sub bb()
-
- Dim mSht As Worksheet
- Dim mRng As Range, E As Range
- Dim ar, mSplit
- Dim mDic As Object
- Dim s%, s1%, s2%
-
-
- Set mDic = CreateObject("scripting.dictionary")
- Set mSht = Worksheets(1)
- With mSht
- Set mRng = .Range("a1", .Range("a" & .Rows.Count).End(xlUp))
-
- For Each E In mRng
-
- If Not mDic.Exists(E.Value) Then
- mDic(E.Value) = E.Offset(, 1).Value
- Else
-
- mDic(E.Value) = mDic(E.Value) & "," & E.Offset(, 1)
-
- End If
-
- Next
-
- s = 1
- s1 = 10
- For Each ar In mDic.Keys
- .Cells(s, s1) = ar
- mSplit = Split(mDic(ar), ",")
- For s2 = 0 To UBound(mSplit)
- .Cells(s, s1 + 1) = mSplit(s2)
- .Cells(1, s1 + 1) = "³¡ªù¦WºÙ"
- s1 = s1 + 1
- Next
- s = s + 1
- s1 = 10
- Next
-
- End With
-
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|