- ©«¤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
|
¦^´_ 2# singo1232001
ÁÂÁ«e½ú«ü¾É
«e½ú¼F®`!
¤§«e¦³ÂsÄý³o¥DÃD:
http://forum.twbts.com/viewthrea ... a=pageD3&page=3
·í®É³£Á٬ݤ£À´,ÁÂÁ«e½ú¦b¦¹©««ü¾É!
°õ¦æ®É¶¡¶Wµu!
¥H¤U¾Ç²ß¨ìªº¤ß±oµù¸Ñ¤@¤U! ¦p¦³«_¥Ç½Ð¨£½Ì!
½Ð«e½ú«ü¥¿¨Ã¦A«ü¾É! ÁÂÁÂ
Option Explicit
Sub °õ¦æ³oÓ()
Dim T
'¡ô«Å§iÅܼÆ
T = Timer
'¡ô¥OT¬O·í¤U®É¶¡ @2
Sheets("¤u§@ªí_1").Range("F:k").ClearContents
'¡ô²M°£ªí_1 "F:k"Äæ¦ìÀx¦s®æ¤º®e
Call test
'¡ô°õ¦æ°Æµ{¦¡ test()
Call test2
'¡ô°õ¦æ°Æµ{¦¡ test2()
MsgBox Timer - T & " ’"
'¡ô¸õ¥X´£¥Üµ¡!Åã¥Ü ³Ì«á®É¶¡ - è誺 ·í¤U®É¶¡ @2
End Sub
Sub test()
Dim v As String, ve As String, sr, d, S, r, i, h, rr
'¡ô«Å§iÅܼÆ
sr = Split("¤u§@ªí_3,¤u§@ªí_4,¤u§@ªí_7", ",") '@1
'¡ô¥O sr¬O¤@ºû°}¦C!3Ó±N³Q·j´Mªº¸ê®Æªí¦WºÙ¥H","²Å¸¹¤ÀӳΠˤJsr
'³o¬On³Q ¤u§@ªí_1(¥H¤UºÙªí_1) AÄæ·j´M¨ú¹ïÀ³Èªº3Ó¤u§@ªí!
Set d = CreateObject("scripting.dictionary")
'¡ô¥Od¬O¦r¨å
Set S = Sheets("¤u§@ªí_1")
'¡ô¥Os ¬Oª«¥ó "ªí_1" ¤u§@ªí
r = S.Cells(Rows.Count, 1).End(3).Row
'¡ô¥Or¬Oªí_1 AÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
For i = 1 To r
'¡ô³]¶¶°j°é±q1 ¨ì AÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
v = S.Cells(i, 1).Value
'¡ô¥Ov¬O ªí_1 ªº°j°éAÄæÀx¦s®æÈ
ve = Left(v, 1)
'¡ô¥Ove ¬O AÄæÀx¦s®æȪº³Ì¥ªÃ䪺¦r¤¸
If d.exists(ve) = False Then
'¡ô¦pªGd¦r¨å¸Ì¨S¦³³oÓ¦r¤¸ªºkey
Set d(ve) = CreateObject("scripting.dictionary")
'¡ôY±ø¥ó¦¨¥ß!´N±N¦¹¦r¤¸¬°key,item¬O¤@Ód¦r¨å¤¤ªº¦r¨å
End If
d(ve)(v) = S.Cells(i, 1).Row
'¡ô¥O d¦r¨å¤¤ªº¦r¨å d(ve)ˤJ AÄæÀx¦s®æȬ°key!Àx¦s®æ¦C¦ì¬°item
Next
ReDim ar(1 To r, 0 To 2) As String
'¡ô«Å§i¦r¦êar °}¦CªºÁa¦V½d³ò¬O1 ¨ì ªí_1 AÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
'¾î¦V½d³ò¬O0 ¨ì2
For h = 0 To 2
'¡ô³]¥~¶¶°j°é±q0 ¨ì2
Set S = Sheets(sr(h))
'¡ô¥Os¬O ³Q·j´Mªº¸ê®Æªí @1
rr = S.Cells(Rows.Count, 1).End(3).Row
'¡ô¥Orr¬O ³Q·j´Mªí AÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
For i = 1 To rr
'¡ô³]¤º¶¶°j°é±q1 ¨ì³Q·jªí AÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
ve = S.Cells(i, 1).Value
'¡ô¥Ove¬O³Q·jªí ªº°j°éAÄæÀx¦s®æÈ(ÃöÁä¦r)
ar(d(Left(ve, 1))(ve), h) = S.Cells(i, 3).Value
'¡ô¥H ³Q·jªíÃöÁä¦r³Ì¥ªÃä¦r¤¸¬°key ¬d¹îd¦r¨å¤¤¹ïÀ³ªºitem¦r¨å
',³o¥H¦rº¬°¦W(key)ªº¦r¨å¤¤¦r¨å,¥H³Q·jªíÃöÁä¦r¬d¹î¹ïÀ³ªº¦C¼Æ(ªí_1),
'¬°ar°}¦Cªº¦C¦ì,h¬O¸ÓÃöÁä¦r·j´M¨ìȪº«ü©wÄæ¦ì
'¡ô¤]´N¬O§â ³Q·jªíÃöÁä¦r·j´M¨ìªºÈ ©ñ¨ì¦r¨å°O¿ýªºar°}¦C¦C¦ì¤¤
Next
Next
Sheets("¤u§@ªí_1").Cells(1, 6).Resize(r, 3) = ar
'¡ô±N ar°}¦CªºÈ±qªí_1ªº[F1]¶}©l¶K¤J
End Sub
Sub test2()
Dim v As String, ve As String, sr, d, S, r, i, h, rr
'¡ô«Å§iÅܼÆ
sr = Split("¤u§@ªí_2,¤u§@ªí_5,¤u§@ªí_6", ",")
'¡ô¥O sr¬O¤@ºû°}¦C!3Ó±N³Q·j´Mªº¸ê®Æªí¦WºÙ¥H","²Å¸¹¤ÀӳΠˤJsr
'³o¬On³Q ¤u§@ªí_1(¥H¤UºÙªí_1) DÄæ·j´M¨ú¹ïÀ³Èªº3Ó¤u§@ªí!
Set d = CreateObject("scripting.dictionary")
'¡ô¥Od¬O¦r¨å
Set S = Sheets("¤u§@ªí_1")
'¡ô¥Os ¬Oª«¥ó ªí_1 ¤u§@ªí
r = S.Cells(Rows.Count, 4).End(3).Row
'¡ô¥Or¬Oªí_1 DÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
For i = 1 To r
'¡ô³]¶¶°j°é±q1 ¨ì DÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
v = S.Cells(i, 4).Value
'¡ô¥Ov¬O ªí_1 ªº°j°éDÄæÀx¦s®æÈ
ve = Left(v, 1)
'¡ô¥Ove ¬O DÄæÀx¦s®æȪº³Ì¥ªÃ䪺¦r¤¸
If d.exists(ve) = False Then
'¡ô¦pªGd¦r¨å¸Ì¨S¦³³oÓ¦r¤¸ªºkey
Set d(ve) = CreateObject("scripting.dictionary")
'¡ôY±ø¥ó¦¨¥ß!´N±N¦¹¦r¤¸¬°key,item¬O¤@Ód¦r¨å¤¤ªº¦r¨å
End If
d(ve)(v) = S.Cells(i, 4).Row
'¡ô¥O d¦r¨å¤¤ªº¦r¨å d(ve)ˤJ DÄæÀx¦s®æȬ°key!Àx¦s®æ¦C¦ì¬°item
Next
ReDim ar(1 To r, 0 To 2) As String
'¡ô«Å§i¦r¦êar °}¦CªºÁa¦V½d³ò¬O1 ¨ì ªí_1 DÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
'¾î¦V½d³ò¬O0 ¨ì2
For h = 0 To 2
'¡ô³]¥~¶¶°j°é±q0 ¨ì2
Set S = Sheets(sr(h))
'¡ô¥Os¬O ³Q·j´Mªº¸ê®Æªí @1
rr = S.Cells(Rows.Count, 1).End(3).Row
'¡ô¥Orr¬O ³Q·j´Mªí AÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
For i = 1 To rr
'¡ô³]¤º¶¶°j°é±q1 ¨ì³Q·jªí AÄ榳¤º®eªºÀx¦s®æ³Ì«á¤@¦C¼Æ
ve = S.Cells(i, 1).Value
'¡ô¥Ove¬O³Q·jªí ªº°j°éAÄæÀx¦s®æÈ(ÃöÁä¦r)
ar(d(Left(ve, 1))(ve), h) = S.Cells(i, 3).Value
'¡ô¥H ³Q·jªíÃöÁä¦r³Ì¥ªÃä¦r¤¸¬°key ¬d¹îd¦r¨å¤¤¹ïÀ³ªºitem¦r¨å
',³o¥H¦rº¬°¦W(key)ªº¦r¨å¤¤¦r¨å,¥H³Q·jªíÃöÁä¦r¬d¹î¹ïÀ³ªº¦C¼Æ(ªí_1),
'¬°ar°}¦Cªº¦C¦ì,h¬O¸ÓÃöÁä¦r·j´M¨ìȪº«ü©wÄæ¦ì
'¡ô¤]´N¬O§â ³Q·jªíÃöÁä¦r·j´M¨ìªºÈ ©ñ¨ì¦r¨å°O¿ýªºar°}¦C¦C¦ì¤¤
Next
Next
Sheets("¤u§@ªí_1").Cells(1, 9).Resize(r, 3) = ar
'¡ô±N ar°}¦CªºÈ±qªí_1ªº[I1]¶}©l¶K¤J
End Sub |
|