- ©«¤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# Andy2483
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÀ˵ø¨ì¦pªGÁ~¸êè¦n¦P¹ï·Óªíª÷ÃB,·|»~§P¬°¸ê®Æ¿ù»~,×¥¿¦p¤U:
Option Explicit
Sub TEST()
Dim Brr, Crr, Z, i&, j%, R&, C%, TT$, T$, T1$, T2$
'¡ô«Å§iÅܼÆ
Set Z = CreateObject("Scripting.Dictionary")
'¡ô¥OZÅܼƬO¦r¨å
Brr = Range([I1], [F65536].End(3)): R = UBound(Brr): C = UBound(Brr, 2)
'¡ô¥OBrrÅܼƬO¥HÀx¦s®æȱa¤Jªº¤Gºû°}¦C,¥OR/CÅܼƬO°}¦CÁa/¾î¦V³Ì¤j¯Á¤Þ¸¹
For i = 2 To UBound(Brr): For j = 1 To 3: T = T & "/" & Brr(i, j): Next: Z(T) = i: T = "": Next
'¡ô³]¶¶°j°é±N3Äæ°}¦CÈ¥H"/"¦r¤¸¦êÁp¦¨ªº·s¦r¦ê·íkey,item¬O¦C¸¹,¯Ç¤JZ¦r¨å¸Ì
Range([D2], [A65536].End(3)).Copy: [F2].Insert Shift:=xlDown
'¡ô¥O±N¹ï·Ó¸ê®Æ½Æ»s´¡¤J¥Ø¼Ð¸ê®Æ¤W¤è
With Range([I1], [F65536].End(3))
.Sort KEY1:=.Item(1), Order1:=1, Key2:=.Item(2), Order2:=1, Key3:=.Item(3), Order3:=2, Header:=1
'¡ô¥O¸ê®Æ°µ¤T¼h±Æ§Ç¦³¼ÐÃD¦C±Æ§Ç,1/2¼h°µº¥¼W,²Ä3¼hº¥´î
Crr = .Value: .ClearContents: [F1].Resize(R, C) = Brr
'¡ô¥OCrrÅܼƬO¥H¸Ó½d³òÀx¦s®æȱa¤Jªº¤Gºû°}¦C
End With
For i = 2 To UBound(Crr)
'¡ô³]¶¶°j°é!¥Oi±q2 ¨ìCrr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
If Crr(i, 4) <> "" And T <> Crr(i, 4) Then T = Crr(i, 4): T1 = Crr(i, 1): T2 = Crr(i, 2): GoTo i01
'¡ô¦pªG°j°éµ¥¯ÅÄæ°}¦CȤ£¬OªÅ¦r¤¸,¥B»PTÅܼƤ£¦P! ´N¥OTÅܼƬO °j°éµ¥¯ÅÄæ°}¦CÈ,
'¥OT1ÅܼƬO°j°é³¡ªùÄæ°}¦CÈ,T2ÅܼƬO°j°é¦~¸êÄæ°}¦CÈ,µM«á¸õ¨ì¼Ð¥Üi01¦ì¸mÄ~Äò°õ¦æ
TT = "/" & T1 & "/" & T2 & "/" & Crr(i, 3)
'¡ô¥OTTÅܼƬO·s²Õ¦X¦r¦ê
If T1 <> Crr(i, 1) Or T2 <> Crr(i, 2) Or Not Z.Exists(TT) Then MsgBox "¸ê®Æ¿ù»~": Exit Sub
'¡ô¦pªG¥Ø¼Ð¸ê®Æ¦³²§±`©Î¹ï·Ó¸ê®Æ²§±`,´N¸õ¥X´£¥Üµ¡~~,µ²§ôµ{¦¡°õ¦æ
Brr(Z(TT), 4) = T
'¡ô¥OZ¦r¨å¸Ì°O¿ý¦C¸¹²Ä4Ä檺Brr°}¦CȬO TÅܼÆ
i01: Next
[F1].Resize(R, C) = Brr
'¡ô¥O[F1]ÂX®iR¦CCÄæ½d³òÀx¦s®æÈ¥H Brr°}¦Cȼg¤J
End Sub |
|