- ©«¤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
|
¦^´_ 31# ã´£³¡ªL
'ÁÂÁ«e½ú
'«á¾Ç¦b¦¹©«¾Ç²ß¨ì
'1.¨S¦³²`¤J¾Ç²ß±o¤£¨ìºëµØ
'2.²ß±o§å¦¸«Å§iÅܼƥB§å¦¸¼Æ»P°j°é·f°t¨Ï¥Î!ªì¶}©l¥u¥H¬°¤Ö«Å§i´XÓÅܼÆ
'3.²ß±o If N(j) > NN Then ¨ú³Ì¤j¼Æªº¤èªk
'4.²ß±o [J4:K4].Resize(NN) = Crr,¥H«e¥u·| [J4].Resize(NN,2)
'5.©P¨ìªº¨¾¿ù»Ýn¦A²Ö¿n¸gÅç!¤~¯à¿ì¨ì
¥H¤U¤ß±oµù¸Ñ½Ð¦b«ü±Ð! ÁÂÁ«e½ú
Sub ³Ì«á®Ä´Á()
Dim Arr, Brr, Crr, R&, i&, j%, N&(1 To 2), NN&, BK As Workbook
'¡ô«Å§iÅܼÆ
R = [¸¤ñ!HE65536].End(xlUp).Row
'¡ô¥OR¬O HEÄæÀx¦s®æ¦³¤º®eªº³Ì«á¤@¦C¼Æ
Arr = Sheets("¸¤ñ").Range("F1:F" & R)
'¡ô¥OArr¬O°}¦C ˤJ¸¤ñªí ªºF1¨ì
'FÄ檺(HEÄæÀx¦s®æ¦³¤º®eªº³Ì«á¤@¦C¼Æ) ªºÈ
Brr = Sheets("¸¤ñ").Range("HD1:HE" & R)
'¡ô¥OBrr¬O°}¦C ˤJ¸¤ñªí ªºHD1¨ì
'HEÄ檺(HEÄæÀx¦s®æ¦³¤º®eªº³Ì«á¤@¦C¼Æ) ªºÈ
ReDim Crr(1 To R, 1 To 2)
'¡ô«Å§iCrr°}¦Cªº¤j¤p ºî¤è¦V 1¨ì HEÄæÀx¦s®æ¦³¤º®eªº³Ì«á¤@¦C¼Æ
'¾î¤è¦V 1 ¨ì 2
For i = 4 To R
'¡ô³]¥~¶¶°j°é ±q4 ¨ì R
For j = 1 To 2
'¡ô³]¤º¶¶°j°é ±q 1 ¨ì 2
If Val(Brr(i, j)) > 0 Then
'¡ô¦pªG ´f ²Î ³o¨âÄæ¸ÌªºÈ¤j©ó0
N(j) = N(j) + 1
'¡ôN¬O³o¨âÄæ²Å¦XIf±ø¥ó¦¸¼ÆªºÅܼÆ!ªì©lȬO0
Crr(N(j), j) = Arr(i, 1)
'¡ôCrr°}¦C±q²Ä¤@¦C¶}©l©ñ¤J²Å¦X±ø¥ó ªº½¦±aÃC¦â
If N(j) > NN Then
'¡ô¦pªG¤j©ó NN
'¡ô·íN(j)=1®É,NNªºªì©lȬO0 !±ø¥ó¦¨¥ß
NN = N(j)
'¡ô±ø¥ó¦¨¥ß!´NÅýNN =²Å¦XIf±ø¥ó¦¸¼Æ
'¡ô·íN(j)=1®É ±ø¥ó¦¨¥ß! NN=1
'¡ô«áÄò¦pªG N(1) N(2)¤£¬Ûµ¥!NN·|¸Ë¤J³Ì¤j¼Æ
End If
End If
Next j
Next i
If NN = 0 Then
'¡ô¦pªGN()ªº³Ì¤j¼ÆNN ¬O0!§¹¥þ¨S¦³²Å¦X±ø¥óªº¸ê®Æ
Exit Sub
'¡ôµ²§ôµ{§Ç
End If
With Sheets("³Ì«á®Ä´Á")
'¡ô±µ¤U¨ÓÃö©ó ³Ì«á®Ä´Áªíªº¬ÛÃöµ{§Ç(«e±¦³ ªÅ¥Õ+"."²Å¸¹ªº")
.[J4:K4].Resize(NN) = Crr
'¡ô¥Ñ ³Ì«á®Ä´Áªí ªº[J4:K4](§t)¶}©l¦V¤UÂX®i NN¦Cªº½d³ò¶K¤JCrrªºÈ
'ÁöµM ReDim Crr(1 To R, 1 To 2)«Å§iªº½d³ò¤ñ ³Ì«áµ²ªG½d³ò¤j!
'¦ý¬Oºë·Çpºâ!¦³®ÄResizeÂX®iµ²ªG½d³ò,´N¤£·|¼vÅT¨ä¥LÀx¦s®æ
If NN <= 1 Then Exit Sub
'¡ô¦pªGN()ªº³Ì¤j¼ÆNN=1,´N µ²§ôµ{§Ç
.[L4:AB4].Copy .[L5:AB5].Resize(NN - 1)
'¡ô±N ³Ì«á®Ä´Áªí[L4:AB4]Àx¦s®æ ½Æ»s¨ì
'³Ì«á®Ä´Áªí[L5:AB5](§t)¶}©l¦V¤UÂX®i NN-1¦C
.[A4:H4].Copy .[A5:H5].Resize(NN - 1)
'¡ô±N ³Ì«á®Ä´Áªí[A4:H4]Àx¦s®æ ½Æ»s¨ì
'³Ì«á®Ä´Áªí[A5:H5](§t)¶}©l¦V¤UÂX®i NN-1¦C
End With
End Sub |
|