- ©«¤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-12-5
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2024-3-5 08:41 ½s¿è
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½Æ²ß¤F¤@¤U,¤è®×µù¸Ñ¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
Option Explicit
Sub TEST()
Dim Arr, Brr, Crr, V$, Z, i&, T$, TT$, A, xA As Range, N%
'¡ô«Å§iÅܼÆ:&¬Oªø¾ã¼Æ,%¬Oµu¾ã¼Æ,$¬O¦r¦êÅܼÆ
Set Z = CreateObject("Scripting.Dictionary")
'¡ô¥OZÅܼƬO ¦r¨å
Set xA = Range([1!G1], [1!A65536].End(3))
'¡ô¥OxAÅܼƬO°Ï°ìÀx¦s®æ(¤u§@ªí "1"¸ÌªºG1Àx¦s®æ¨ì AÄæ³Ì«á¦³¤º®eÀx¦s®æ)
xA.Offset(1, 12).ClearContents: Brr = xA
'¡ô¥OxAÀx¦s®æ°¾²¾¤U1¦C¥k12Ä檺°Ï°ìÀx¦s®æ¤º®e²M°£,¥OBrrÅܼƬO¥HxAÀx¦s®æȱa¤Jªº¤Gºû°}¦C
For i = 2 To UBound(Brr)
'¡ô³]¶¶°j°é!¥Oi±q2 ¨ìBrr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
T = Format(Trim(Brr(i, 2)), "0000000"): V = Format(Val(Brr(i, 7)), "0000000"): TT = T & "/" & V
'¡ô¥OTÅܼƬOi°j°é¦C2ÄæBrr°}¦CÈ¥h°£ÀY§ÀªÅ¥Õ¦r¤¸«á,Âà¤Æ¬°7½X¼ÆȪº¦r¦ê,¦pªG¤£¨¬7½X«h¥ª°¼¥H0 ¸É¨¬
'¡ô¥OVÅܼƬOi°j°é¦C7ÄæBrr°}¦CÈÂà¤Æ¬°¼ÆÈ«á,¦AÂà¤Æ¬°7½X¼ÆȪº¦r¦ê,¦pªG¤£¨¬7½X«h¥ª°¼¥H0 ¸É¨¬
'¡ô¥OTTÅܼƥH"/"²Å¸¹³s±µT»PVÅܼƩҲզ¨ªº·s¦r¦ê
Z(TT) = i
'¡ô¥O¥HTTÅܼƬ°key,item¬OiÅܼÆ(¦C¸¹)¯Ç¤JZ¦r¨å¤¤
Next
Arr = [1!M1].Resize(UBound(Brr), 3)
'¡ô¥OArrÅܼƬO ¤u§@ªí "1"ªºM1Àx¦s®æÂX®i¦V¤U/¦V¥k°Ï°ìÀx¦s®æȱa¤Jªº¤Gºû°}¦C
A = Array(Range([KH!C1], [KH!A65536].End(3)), Range([KH!J1], [KH!H65536].End(3)), Range([KP!C1], [KP!A65536].End(3)), Range([KP!K1], [KP!I65536].End(3)))
'¡ô¥OAÅܼƬO 4Ó°Ï°ìÀx¦s®æªº¤@ºû°}¦C
For Each Crr In A
'¡ô³]³v¶µ°j°é!¥OCrrÅܼƬO A°}¦C¸Ìªº°}¦CÈ(°Ï°ìÀx¦s®æ)
Crr = Crr: N = N + 1
'¡ô¥OCrrÅܼÆÂàÅܬ° ¥HCrr°Ï°ìÀx¦s®æȱa¤Jªº¤Gºû°}¦C (PS:CrrÅܼƫŧi¬O³q¥Î«¬ÅܼÆ,©Ò¥H¥i¥H¥ÑÀx¦s®æÅܬ°¤Gºû°}¦C)
For i = 3 To UBound(Crr)
'¡ô³]¶¶°j°é!¥Oi±q3¨ìCrr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
T = Format(Trim(Crr(i, 1)), "0000000"): V = Format(Val(Crr(i, 2)), "0000000"): TT = T & "/" & V
'¡ô¦¹¼Ðªº¬°Crr°}¦C,T.V.TTÅܼƷN¸q¦P¤W
If Z.Exists(TT) Then
'¡ô¦pªGZ¦r¨å¸Ì¦³ TTÅܼƪºkey?
If Arr(Z(TT), 1) = "" Then
'¡ô¤S¦pªGArr°}¦C¸Ì(Z¦r¨å©Ò°O¾Ðªº¦C¸¹1Äæ)°}¦CȬOªÅ¦r¤¸?
Arr(Z(TT), 1) = Crr(1, 1)
'¡ô¥O¸Ó°}¦CÈ¥H 1¦C1ÄæCrr°}¦Cȼg¤J
ElseIf InStr("/" & Arr(Z(TT), 1) & "/", "/" & Crr(1, 1) & "/") = 0 Then
'¡ô§_«h¦pªG¸Ó°}¦CȨS¦³ 1¦C1ÄæCrr°}¦CÈ
Arr(Z(TT), 1) = Arr(Z(TT), 1) & "/" & Crr(1, 1)
'¡ô¥O¸Ó°}¦CȬO¥H ¦Û¨¦r¦ê³s±µ 1¦C1ÄæCrr°}¦CÈ©Ò²Õ¦¨ªº·s¦r¦ê
End If
Arr(Z(TT), N \ 3 + 2) = Crr(1, 3)
'¡ô¥O¦bArr°}¦C¸Ì¼g¤J 1¦C3ÄæCrr°}¦CÈ
End If
Next
Next
[1!M1].Resize(UBound(Brr), 3) = Arr
'¡ô¥O¤u§@ªí "1"ªºM1Àx¦s®æÂX®iªº½d³ò¸Ì¼g¤JArr°}¦CÈ
End Sub |
|