- ©«¤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 ©ó 2023-5-25 16:32 ½s¿è
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
List¸ê®Æ®w:
¸ê®Æªí(·s¤ñ¹ï¸ê®Æ):
µ²ªGªí°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim Brr, Y, R&, i&, j&, T$
'¡ô«Å§iÅܼÆ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OYÅܼƬO¦r¨å
Brr = Range([List!C1], [List!A65536].End(xlUp))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥HListªíA~CÄæÀx¦s®æȱa¤J°}¦C¸Ì
For i = 2 To UBound(Brr)
'¡ô³]¶¶°j°é
T = Brr(i, 1) & Brr(i, 2) & Brr(i, 3): Y(T) = i
'¡ô¥O¥H¨CÓ°j°é3ÄæȲզ¨ªº·s¦r¦ê·íkey,item¬O¦C¸¹,¯Ç¤JY¦r¨å
Next
Brr = Range([¸ê®Æ!C1], [¸ê®Æ!A65536].End(xlUp))
'¡ô¥OBr°}¦C,´«¸Ë¸ê®ÆªíA~CÄæÀx¦s®æÈ
For i = 2 To UBound(Brr)
'¡ô³]¶¶°j°é
T = Brr(i, 1) & Brr(i, 2) & Brr(i, 3)
If Y(T) <> "" Then GoTo i01
'¡ô¦pªG¥H°j°é3ÄæȲզ¨ªº·s¦r¦ê¬dY¦r¨å±oitemȤ£¬OªÅªº,
'´N¸õ¨ì¼Ð¥Üi01¦ì¸mÄ~Äò°õ¦æ
R = R + 1
'¡ô¥ORÅܼƲ֥[1
For j = 1 To 3: Brr(R, j) = Brr(i, j): Next
'¡ô³]¶¶°j°é!±NBrr°}¦CÈ©¹¤WÁÃ,±Nì°}¦CÈÂл\
i01: Next
If R = 0 Then MsgBox "µL·s¼W": GoTo i02
'¡ô¦pªGRÅܼƬOªì©lÈ0,´N¸õ¨ì¼Ð¥Üi02¦ì¸mÄ~Äò°õ¦æ
With Sheets("¦¹¦¸·s¼W")
.UsedRange.Offset(1, 0).Clear
'¡ô±Nµ²ªGªí¦³¨Ï¥ÎÀx¦s®æ©¹¤U°¾²¾1¦Cªº½d³ò²M°£
.[A2].Resize(R, 3) = Brr
'¡ô¥OBrr°}¦Cȼg¤Jµ²ªGªí¤¤,¶W¥X½d³òªº°}¦CÈ©¿²¤
End With
i02: Set Y = Nothing: Erase Brr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub
=============================================
¸É¥R: ¥H¤U¬O±Nµ²ªG¸ê®ÆÁäJ¥t¤@°}¦Cªº¤èªk
Option Explicit
Sub TEST_1()
Dim Brr, Crr, Y, R&, i&, j&, T$
'¡ô«Å§iÅܼÆ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OYÅܼƬO¦r¨å
Brr = Range([List!C1], [List!A65536].End(xlUp))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥HListªíA~CÄæÀx¦s®æȱa¤J°}¦C¸Ì
For i = 2 To UBound(Brr)
'¡ô³]¶¶°j°é
T = Brr(i, 1) & Brr(i, 2) & Brr(i, 3): Y(T) = i
'¡ô¥O¥H¨CÓ°j°é3ÄæȲզ¨ªº·s¦r¦ê·íkey,item¬O¦C¸¹,¯Ç¤JY¦r¨å
Next
Brr = Range([¸ê®Æ!C1], [¸ê®Æ!A65536].End(xlUp))
'¡ô¥OBr°}¦C,´«¸Ë¸ê®ÆªíA~CÄæÀx¦s®æÈ
ReDim Crr(1 To UBound(Brr), 1 To 3)
'¡ô«Å§iCrrÅܼƬO ¤GºûªÅ°}¦C,Áa¦V½d³ò¦PBrr,¾î¦V1~3
For i = 2 To UBound(Brr)
'¡ô³]¶¶°j°é
T = Brr(i, 1) & Brr(i, 2) & Brr(i, 3)
If Y(T) <> "" Then GoTo i01
'¡ô¦pªG¥H°j°é3ÄæȲզ¨ªº·s¦r¦ê¬dY¦r¨å±oitemȤ£¬OªÅªº,
'´N¸õ¨ì¼Ð¥Üi01¦ì¸mÄ~Äò°õ¦æ
R = R + 1
'¡ô¥ORÅܼƲ֥[1
For j = 1 To 3: Crr(R, j) = Brr(i, j): Next
'¡ô³]¶¶°j°é!±NBrr°}¦Cȼg¤JCrr°}¦C¤¤
i01: Next
If R = 0 Then MsgBox "µL·s¼W": GoTo i02
'¡ô¦pªGRÅܼƬOªì©lÈ0,´N¸õ¨ì¼Ð¥Üi02¦ì¸mÄ~Äò°õ¦æ
With Sheets("¦¹¦¸·s¼W")
.UsedRange.Offset(1, 0).Clear
'¡ô±Nµ²ªGªí¦³¨Ï¥ÎÀx¦s®æ©¹¤U°¾²¾1¦Cªº½d³ò²M°£
.[A2].Resize(R, 3) = Crr
'¡ô¥OCrr°}¦Cȼg¤Jµ²ªGªí¤¤,¶W¥X½d³òªº°}¦CÈ©¿²¤
End With
i02: Set Y = Nothing: Erase Brr, Crr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|