- ©«¤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
|
¦^´_ 3# ã´£³¡ªL
ÁÂÁ«e½ú
«á¾ÇÂǦ¹©«¾Ç²ß«e½úªº¤è®×µy§@ÅܤÆ,¤è®×¾Ç²ß¤ß±o¦Ü¸Ñ¦p¤U,½Ð«e½ú¦A«ü¾É
¸ê®Æªí:
µ²ªGªí°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim Arr, xD, i&, T1$, T2$, T3$
'¡ô«Å§iÅܼÆ
Set xD = CreateObject("Scripting.Dictionary")
'¡ôxDÅܼƬO ¦r¨å
Arr = Range([¦ì¸m!A1], [¦ì¸m!D65536].End(xlUp))
'¡ô¥OArrÅܼƬO ¤Gºû°}¦C,¥HÀx¦s®æȱa¤J°}¦C¤¤
For i = 2 To UBound(Arr)
'¡ô³]¶¶°j°é
T1 = Arr(i, 1): T2 = Arr(i, 4)
'¡ô¥O°j°éArr°}¦CÈ¥HÅܼƩӸË,¶¶¹D©w¸q¨äȬO¦r¦ê
If T1 = "" Or T2 = "" Then GoTo i01
'¡ô¦pªG«~¸¹©Î «~¦W¬OªÅªº,¤£°õ¦æ!¸õ¨ì i01¼Ð¥Ü¦ì¸mÄ~Äò°õ¦æ
T3 = T1 & "|" & T2: xD(T3) = xD(T3) + 1
'¡ô¥OT3¬O¥H"|"¶¡¹jªº²Õ¦X¦r¦ê,
'¥OT3ÅܼƷíkey,item¬O¦Û¨²Ö¥[ 1,¯Ç¤JxD¦r¨å
If xD(T3) = 1 Then xD(T1) = Trim(xD(T1) & " " & T2)
'¡ô¦pªGT3ÅܼƬO²Ä1¦¸¯Ç¤J¦r¨å(itemÈ=1),
'´N¥OT1ÅܼƷíkey,item¬O¦Û¨È³s±µT2ÅܼÆ,¤¤¶¡¥HªÅ¥Õ¦r¤¸¹j¶},
'³Ì«á¦A¥h°£ÀY§ÀªºªÅ¥Õ¦r¤¸
i01: Next i
Arr = Range([®Æ¥ó!A1], [®Æ¥ó!A65536].End(xlUp))
'¡ô¥OArrÅܼƬO ¤Gºû°}¦C,¥HÀx¦s®æȱa¤J°}¦C¤¤
For i = 2 To UBound(Arr)
'¡ô³]¶¶°j°é
Arr(i - 1, 1) = Replace(xD(Arr(i, 1) & ""), " ", ",")
'¡ô¥O¥H°j°éArr°}¦CȬdxD¦r¨å±o¨ìitemÈ,¸g¸m´«ªÅ¥Õ¦r¤¸¬°³r¸¹,
'Âл\±¼ìArr°}¦CÈ
Next i
[®Æ¥ó!C2].Resize(UBound(Arr) - 1) = Arr
'¡ô¥O[®Æ¥ó!C2]ÂX®i¦V¤UArr°}¦C³Ì¤j¯Á¤Þ¸¹-1ÓÀx¦s®æ½d³òÈ,
'¥HArr°}¦C±a¤J,¶W¹L¦¹½d³òªº°}¦CȳQ©¿²¤
End Sub |
|