- ©«¤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-11-29
|
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
¸ê®Æªí:
µ²ªGªí:
Option Explicit
Sub TEST()
Dim Brr, Crr, Y, R1&, R&, i&, j&, TT$, T2$, T3$, T4$, T5$
'¡ô«Å§iÅܼÆ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OYÅܼƬO ¦r¨å
Brr = Range([Date!F2], [Date!A65536].End(xlUp))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥H¸ê®ÆªíÀx¦s®æȱa¤J
ReDim Crr(1 To 1000, 1 To 7)
'¡ô«Å§iCrrÅܼƬO¤GºûªÅ°}¦C,Áa¦V¯Á¤Þ¸¹1~1000,¾î¦V1~7
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é
T2 = Brr(i, 2): T3 = Brr(i, 3): T4 = Brr(i, 4): T5 = Brr(i, 5)
'¡ô¥OT2~T5ÅܼƸˤJ°}¦CÈ
TT = T2 & "|" & T3 & "|" & T4 & "|" & T5
'¡ô¥OTTÅܼƬO²Õ¦X¦r¦ê,¥Î¨ÓÂo«½Æ¥Îªºkey
If Y(TT) = "" Then
'¡ô¦pªG¥HTTÅܼƬdY¦r¨å±oitemȬO""
R = R + 1
'¡ô¥ORÅܼƲ֥[1 (¥Î¨Ó²Ö¥[Crr°}¦C³oµ²ªG°}¦Cªº¦C¸¹)
For j = 1 To 4: Crr(R, j) = Brr(i, j + 1): Next
'¡ô±NBrr°}¦C2~5Äæ¼g¤JCrr°}¦C(1~4)Äæ«ü©wªºRÅܼƦC¸¹
Crr(R, 5) = Val(Brr(i, 6))
'¡ôCrr°}¦C²Ä5Äæ©ñ¤J¸ê®Æªíªº¼Æ¶q (¥ÎVal()±N¦r¦êÂର¼ÆÈ)
Crr(R, 6) = 1
'¡ôCrr°}¦C²Ä6Äæ¬O¼g¤J1 (²Ä1½c)
Crr(R, 7) = Brr(i, 1)
'¡ôCrr°}¦C²Ä7Äæ¬O¼g¤J½c¸¹ (²Ä1½c¸¹)
Y(TT) = R: GoTo i01
'¡ô¥O¥HTTÅܼƬ°key,item¬O RÅܼÆ(¦C¸¹),¯Ç¤JY¦r¨å¤¤
'¥Oµ{§Ç¸õ¨ì¼Ð¥Ü i01¦ì¸mÄ~Äò°õ¦æ
End If
R1 = Y(TT)
'¡ô¥OR1ÅܼƬO ¥HTTÅܼƬdY¦r¨å±oitemÈ (¥Î¨Ó«ü¦VCrr°}¦C¦C¸¹)
'¬O²Ä2¦¸¥H¤W¥X²{ªºkey¤~·|¶]¨ì³o¸Ì
Crr(R1, 5) = Crr(R1, 5) + Val(Brr(i, 6))
'¡ô¥O¼Æ¶q²Ö¥[
Crr(R1, 6) = Crr(R1, 6) + 1
'¡ô¥O½c¼Æ²Ö¥[
Crr(R1, 7) = Crr(R1, 7) & "," & Brr(i, 1)
'¡ô¥O½c¸¹²K¥[¦bCrr°}¦C²Ä7Äæ«á±
i01: Next
With [Result!A2].Resize(R, 7)
'¡ô¥H¤U¬OÃö©óµ²ªGªí¹wpn¼g¤J·sµ²ªG½d³òÀx¦s®æªºµ{§Ç
.EntireColumn.Clear
'¡ô¥O³o¨ÇÄæ¦ì°µ²M°£
[Result!A1:G1] = [{"q³f³æ","ªO¸¹","®Æ¸¹","ì²£¦a","¼Æ¶q¦Xp","½c¼Æ","½c¸¹µù°O"}]
'¡ô¥Oµ²ªGªí¼g¤J¼ÐÃD¦C
.Value = Crr
'¡ô¥OCrr°}¦Cȼg¤J³o¨Ç½d³òÀx¦s®æ,¶W¹L¦¹½d³òªº°}¦CÈ©¿²¤
.EntireColumn.AutoFit
'¡ô¥O³o¨ÇÄæ¦ìÄæ¼e¦Û°Ê½Õ¾ã
Intersect(.Cells, [G:G]).NumberFormatLocal = "@"
'¡ô¥O²Ä7Ä檺®æ¦¡¬O ¤å¦r
End With
Set Y = Nothing: Erase Brr, Crr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|