- ©«¤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-11-28
|
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«¥H1#½d¨Ò½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
¸ê®Æªí:
µ²ªGªí:
Option Explicit
Sub TEST()
Dim Brr, Crr(10, 11), Z, A, i&, R&, C%, T$, T3$, T4$, xR
'¡ô«Å§iÅܼÆ
'Application.ScreenUpdating = False
Set Z = CreateObject("Scripting.Dictionary")
'¡ô¥OZÅܼƬO ¦r¨å
Brr = Range([¸ê®Æ®w!E2], [¸ê®Æ®w!A65536].End(3))
'¡ô¥OBrrÅܼƬO±a¤J½d³òÀx¦s®æȪº¤Gºû°}¦C
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!i±q1¨ìBrr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
T3 = Trim(Brr(i, 3)): T4 = Trim(Brr(i, 4))
'¡ô¥OT3ÅܼƬOi°j°é¦C²Ä3ÄæBrr°}¦CÈ,¥OT4ÅܼƬOi°j°é¦C²Ä4ÄæBrr°}¦CÈ
If T3 = "" Or T4 = "" Then GoTo i01 Else T = T3 & "|" & T4
'¡ô¦pªG³W®æ©Î§å¸¹¬OªÅªº!´N¸õ¨ì¼Ð¥Ü i01¦ì¸mÄ~Äò°õ¦æ,
'§_«h´N¥OTÅܼƬO¥H"|"²Å¸¹³s±µT3»PT4ÅܼƲզ¨ªº·s¦r¦ê
A = Z(T): R = Z(T & "/r"): C = Z(T & "/c")
'¡ô¥OAÅܼƬO¥HTÅܼƬdZ¦r¨å¦^¶ÇitemÈ,
'¥ORÅܼƬO¥HTÅܼƳs±µ"/r"²Õ¦¨ªº·s¦r¦ê,¬dZ¦r¨å¦^¶ÇitemÈ
'¥OCÅܼƬO¥HTÅܼƳs±µ"/c"²Õ¦¨ªº·s¦r¦ê,¬dZ¦r¨å¦^¶ÇitemÈ
If Not IsArray(A) Then A = Crr: A(0, 0) = "§å¸¹": A(0, 1) = T3: R = 1: Z(T & "/³W®æ") = "³W®æ" & T4
'¡ô¦pªGAÅܼƤ£¬O°}¦C!´N¥OAÅܼƬOCrrªÅ°}¦C,¥O³Ì¥ª¤W¨¤°}¦CȬO "§å¸¹"¦r¦ê,
'¥O0¦C/1Äæ°}¦CȬOT3ÅܼÆ(§å¸¹),¥ORÅܼƬO 1
'¥OTÅܼƳs±µ "/³W®æ"²Õ¦¨ªº·s¦r¦ê¬°key,item¬O "³W®æ"¦r¦ê³s±µT4ÅܼƲզ¨ªº·s¦r¦ê,¯Ç¤JZ¦r¨å¤¤
C = C + 1
'¡ô¥OCÅܼƲ֥[ 1
If C = 11 Then C = 1: R = R + 1
'¡ô¦pªGCÅܼƬO 11,´N¥OC=1,R+1 (°}¦C´«¦æ©ñµ²ªGÈ)
A(R, C) = Val(Brr(i, 5))
'¡ô¥O«¶qÈ©ñ¤J°}¦C¸Ì
Z(T & "/r") = R: Z(T & "/c") = C: Z(T) = A
'¡ô¥O¦C¼Æ»PÄæ¼Æ¬ö¿ý¦b¦r¨å¤¤
'¥OA¤Gºû°}¦C©ñ¦^¦r¨å¤¤
i01: Next
Sheets("³øªí").UsedRange.EntireRow.Delete
'¡ô¥Oªºµ²ªG§R°£
Set xR = [³øªí!A1]
'¡ô¥OxRÅܼƬOª«¥ó ("³øªí"¤u§@ªíªº[A1]Àx¦s®æ)
For Each A In Z.KEYS
'¡ô³]³v¶µ°j°é!¥OAÅܼƬO Z¦r¨å¸Ìªºkey¤§¤@
If InStr(A, "/") Then GoTo A01 Else R = Z(A & "/r")
'¡ô¦pªGAÅܼƸ̦³¥]§t"/"¦r¤¸!´N¸õ¨ì¼Ð¥ÜA01¦ì¸mÄ~Äò°õ¦æ,§_«h´N¥ORÅܼƨú¥X¬ö¿ý¦bZ¦r¨åªº¦C¼Æ
With xR.Resize(R + 3, 12)
'¡ô¥H¤U¬OÃö©óµ²ªG½d³òÀx¦s®æªºµ{§Ç
.Value = Z(A)
'¡ô¥O¸Ó½d³òÀx¦s®æÈ,¥HAÅܼƬdZ¦r¨å¦^¶Çªº°}¦Cȼg¤J
.Cells(R + 3, 1) = Z(A & "/³W®æ"): .Cells(R + 3, 2) = "¼Æ¶q": .Cells(R + 3, 4) = "¤pp:"
'¡ô¥O¸Ó½d³òÀx¦s®æ³Ì«á¦C1,2,4ÄæÀx¦s®æ¼g¤J¦r¦ê
.Cells(R + 3, 3) = "=COUNT(" & xR.Resize(R, 12).Offset(1).Address & ")"
'¡ô¥O¸Ó½d³òÀx¦s®æ³Ì«á¦C²Ä3ÄæÀx¦s®æ¼g¤J «DªÅ®æªºÀx¦s®æ¼Æ¤½¦¡=COUNT()
.Cells(R + 3, 5) = "=SUM(" & xR.Resize(R, 12).Offset(1).Address & ")"
'¡ô¥O¸Ó½d³òÀx¦s®æ³Ì«á¦C²Ä5ÄæÀx¦s®æ¼g¤J Àx¦s®æ¼ÆÈÁ`©M¤½¦¡=SUM()
For i = 7 To 10: .Borders(i).Weight = 4: Next
'¡ô¥O¸ÓÀx¦s®æ½d³ò³Ì¥~³ò³]¬°²Ê®æ½u
End With
Set xR = xR(R + 4, 1)
'¡ô¥OxRÅܼƬO¤UÓµ²ªG½d³òªº²Ä1®æÀx¦s®æ
A01: Next
End Sub |
|