- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim Brr, Crr, Y, R&, C%, i&, N&, TT$, T1$, T2$, Mc%
'¡ô«Å§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)
'¡ô«Å§iCrr¬O ¤GºûªÅ°}¦C,Áa¦V½d³ò¦PBrr°}¦C,¾î¦V½d³ò±q1~100
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é
T1 = Brr(i, 1): T2 = Brr(i, 2): TT = T1 & "|" & T2
'¡ô¥OÅܼƲ±¸Ë°}¦CÈ,¥OTTÅܼƬOÂo«½Æªº²Õ¦X¦r¦ê
If Y(TT) <> "" Then GoTo i01
'¡ô¦pªGTTÅܼƦbY¦r¨å¸Ì¤w¸g¦³³okey!´N¸õ¨ìi01¼Ð¥Ü¦ì¸mÄ~Äò°õ¦æ
If Y(T1) = "" Then
'¡ô¦pªG¬OAÄæªì¦¸¥X²{ªº¶µ¥Ø?
N = N + 1
'¡ô¥ONÅܼƲ֥[1 («ü©w¦¹AÄ涵¥Ø¦bCrr°}¦C¸Ìªº¯Á¤Þ¦C¸¹)
Y(T1) = N
'¡ô±N¯Á¤Þ¦C¸¹¥H AÄ涵¥Ø·íkey,¯Ç¤JY¦r¨å¸Ì
Crr(N, 1) = Brr(i, 1)
'¡ô¥ý±NAÄ涵¥Ø¼g¤JCrr°}¦C¸Ì
Y(T1 & "/c") = 1
'¡ô³o¬On°O¿ý¾î¦VÄæ¦ìªºkey,item¬O1 (¦]¬°²Ä1Äæ¤w¸g³Q AÄ涵¥Ø¥Î±¼¤F)
End If
R = Y(T1)
'¡ô¤£ºÞAÄ涵¥Ø¬O¤£¬Oº¦¸¥X²{!
'¥ORÅܼƸËAÄ涵¥Ø©Ò±aªºitemÈ
C = Y(T1 & "/c")
'¡ô¥OCÅܼƬO AÄ涵¥Ø©Ò±aªºÄæ¼Æ
C = C + 1
'¡ô¥OCÅܼƲ֥[1
Y(T1 & "/c") = C
'¡ô¥OAÄ涵¥Ø©Ò±aªºÄæ¼Æ¸Ë·sªºÄæ¼ÆC
Y(TT) = 1
'¡ô¥O¦bY¦r¨å¸ÌªºTTÅܼÆkey,itemȧאּ1(Åý«á°j°éÂo«½Æ)
Crr(R, C) = T2
'¡ô¥OBÄ涵¥Ø¼g¤JCrr°}¦C¤¤
If C > Mc Then Mc = C
'¡ô³oMcÅܼƬO¬°¤Fn°»´úCrr°}¦C©Ò»ÝnªºÄæ¼Æ
i01: Next
[I1].Resize(N, Mc) = Crr
'¡ô¥OCrr°}¦Cȱq[I1]¶}©l¼g¤JÀx¦s®æ¸Ì
Set Y = Nothing: Erase Brr, Crr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|