- ©«¤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
|
¦^´_ 2# ã´£³¡ªL
ÁÂÁ½׾Â,ÁÂÁ«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð«e½ú¦A«ü¾É
°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST_1()
Dim Brr, Y, A, i&, j%, Ta$, Tb$, Td$, TT$
'¡ô«Å§iÅܼÆ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OYÅܼƬO¦r¨å
Brr = Range([F1], [A65536].End(3))
'¡ô¥OÅܼƬO¤Gºû°}¦C¨Ã¥HÀx¦s®æÈˤJ
A = Array(, 1, 2, 4, 6)
'¡ô³]Ó¤@ºû°}¦CÅý«áÄòªºµ²ªG°j°é§ì¨ú«ü©wÄæ¦ì
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é
Ta = Brr(i, 1): Tb = Brr(i, 2): Td = Brr(i, 4): TT = Ta & "|" & Tb
If Y(TT) = "" Then
'¡ô³oºÃ°Ý¥y¤w¸g¤£ª¾¤£Ä±±N key¬OTTÅܼÆ,item¬O"" ,¯Ç¤J¦bY¦r¨å¤¤¤F
Y(TT) = Y.Count
'¡ô¯Á©Ê´N¨Ì·í¤Ukeyªº¼Æ¶q·íÅܼƬö¿ý¦¹key¦b°}¦C¤¤ªº¯Á¤Þ¦C¸¹
For j = 1 To 4: Brr(Y.Count, j) = Brr(i, A(j)): Next: GoTo i01
'¡ô¦]¬°¬Oº¦¸¯Ç¤J¦¹key,©Ò¥H±N¦UÄæ¦ìȱa¤J«ü©w¦ì¸m,Âл\°}¦CÈ,
'¡ô¥H¤W´N¤w¸g³B²z¤Fº¦¸È,¤£¥²²Ö¥[¼Æ¶q,©Ò¥H¸õ¨ìi01«ü©w¦ì¸mÄ~Äò°õ¦æ
End If
Brr(Y(TT), 4) = Brr(Y(TT), 4) + Brr(i, 6)
'¡ô¦pªGµ{§Ç¯à¶]¨ì³o¸Ì,¥Nªí¤£¬Oº¦¸,±N¸Ókey©Ò±aªºitem½Õ¥X¨Ó(¯Á¤Þ¦C¸¹),
'Åý¼Æ¶q°µ²Ö¥[
If InStr(" " & Brr(Y(TT), 3) & " ", " " & Td & " ") = 0 Then
Brr(Y(TT), 3) = Trim(Brr(Y(TT), 3) & " " & Td)
End If
'¡ô±N¤£«½Æ¤u§@¤Hû¯Ç¤J
i01: Next
[L:O].ClearContents
'¡ô²M°£µ²ªGÀx¦s®æ¸ê®Æ
If Y.Count > 1 Then [L1].Resize(Y.Count, 4) = Brr
'¡ô¦pªG¦r¨å¸Ìkeys¼Æ>1!´N±q[L1]¶}©l¶K¤JBrr°}¦C§½³¡È
Set Y = Nothing: Erase Brr
'¡ôÄÀ©ñÅܼÆ
End Sub |
|