- ©«¤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 14:57 ½s¿è
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß±N¤W¤@©«3Ó°}¦C´î¬°2Ó°}¦C,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
Option Explicit
Sub TEST_3()
Dim Arr, Brr, Y, R&, i&, j&, ST
'¡ô«Å§iÅܼÆ
ST = Timer
'¡ô¥OSTÅܼƬO ·í¤U®É¶¡
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OYÅܼƬO ¦r¨å
Brr = Range([¤u§@ªí2!A1], [¤u§@ªí2!A65536].End(3))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥Hªí2ªºAÄæÀx¦s®æȱa¤J°}¦C¤¤
For i = 1 To UBound(Brr): Y(Brr(i, 1) & "") = i: Next
'¡ô³]¶¶°j°é!¥O¥HªÑ²¼¥N¸¹·íkey,item¬Oi°j°é¼Æ(¦C¸¹),¯Ç¤JY¦r¨å¤¤
Arr = Range([¤u§@ªí1!H1], [¤u§@ªí1!A65536].End(3))
'¡ô¥OArrÅܼƬO ¤Gºû°}¦C,¥Hªí1ªºA~HÄæÀx¦s®æȱa¤J°}¦C¤¤
For i = 1 To UBound(Arr)
'¡ô³]¶¶°j°é!
If Y(Arr(i, 2) & "") = "" Then GoTo i01
'¡ô¦pªG¥HªÑ²¼¥N¸¹¬dY¦r¨å±oitemȬOªÅªº!´N¸õ¨ìi01¼Ð¥Ü¦ì¸mÄ~Äò°õ¦æ
R = R + 1
'¡ô¥ORÅܼƲ֥[1 (µ²ªGÈ©ñ¸mªº¦C¸¹)
For j = 1 To 8: Arr(R, j) = Arr(i, j): Next
'¡ô³]¶¶°j°é!±NArr°}¦CÈ©¹¤WÁÃ,Âл\±¼ì°}¦CÈ
Y(Arr(i, 2) & "") = ""
'¡ô¥O¥HªÑ²¼¥N¸¹ªºkey¹ïÀ³ªºitem§ï¬°ªÅªº
i01: Next
With Sheets("¤u§@ªí1")
.UsedRange.Clear
'¡ô¥O²M°£Â¸ê®Æ
.[A1].Resize(R, 8) = Arr
'¡ô¥OArr°}¦Cȼg¤JÀx¦s®æ¸Ì,¶W¹L³oÀx¦s®æ½d³òªº°}¦CÈ©¿²¤
End With
Set Y = Nothing: Erase Arr, Brr
'¡ô¥OÄÀ©ñÅܼÆ
MsgBox Format(Timer - ST, "0.0’")
'¡ô¥O¸õ¥X´£¥Üµ¡,Åã¥Ü¦¹·í¤U®É¶¡-STÅܼƫáÂà¤Æ¬°¦³1¦ì¤p¼Æªº"?.?¬í"¦r¦ê
End Sub
==============================================================
¥H¤U¬O¾Ç²ß±N¤W¤@Code ±N2Ó°}¦C´î¬°1Ó°}¦C,¾Ç²ß¤è®×¦p¤U
Option Explicit
Sub TEST_4()
Dim Brr, Y, R&, i&, j&, ST
'¡ô«Å§iÅܼÆ
ST = Timer
'¡ô¥OSTÅܼƬO ·í¤U®É¶¡
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OYÅܼƬO ¦r¨å
Brr = Range([¤u§@ªí2!A1], [¤u§@ªí2!A65536].End(3))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥Hªí2ªºAÄæÀx¦s®æȱa¤J°}¦C¤¤
For i = 1 To UBound(Brr): Y(Brr(i, 1) & "") = i: Next
'¡ô³]¶¶°j°é!¥O¥HªÑ²¼¥N¸¹·íkey,item¬Oi°j°é¼Æ(¦C¸¹),¯Ç¤JY¦r¨å¤¤
Brr = Range([¤u§@ªí1!H1], [¤u§@ªí1!A65536].End(3))
'¡ô¥OBrr°}¦C´«¸Ëªí1ªºA~HÄæÀx¦s®æÈ
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!
If Y(Brr(i, 2) & "") = "" Then GoTo i01
'¡ô¦pªG¥HªÑ²¼¥N¸¹¬dY¦r¨å±oitemȬOªÅªº!´N¸õ¨ìi01¼Ð¥Ü¦ì¸mÄ~Äò°õ¦æ
R = R + 1
'¡ô¥ORÅܼƲ֥[1 (µ²ªGÈ©ñ¸mªº¦C¸¹)
For j = 1 To 8: Brr(R, j) = Brr(i, j): Next
'¡ô³]¶¶°j°é!±NBrr°}¦CÈ©¹¤WÁÃ,Âл\±¼ì°}¦CÈ
Y(Brr(i, 2) & "") = ""
'¡ô¥O¥HªÑ²¼¥N¸¹ªºkey¹ïÀ³ªºitem§ï¬°ªÅªº
i01: Next
With Sheets("¤u§@ªí1")
.UsedRange.Clear
'¡ô¥O²M°£Â¸ê®Æ
.[A1].Resize(R, 8) = Brr
'¡ô¥OBrr°}¦Cȼg¤JÀx¦s®æ¸Ì,¶W¹L³oÀx¦s®æ½d³òªº°}¦CÈ©¿²¤
End With
Set Y = Nothing: Erase Brr
'¡ô¥OÄÀ©ñÅܼÆ
MsgBox Format(Timer - ST, "0.0’")
'¡ô¥O¸õ¥X´£¥Üµ¡,Åã¥Ü¦¹·í¤U®É¶¡-STÅܼƫáÂà¤Æ¬°¦³1¦ì¤p¼Æªº"?.?¬í"¦r¦ê
End Sub |
|