- ©«¤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# ã´£³¡ªL
ÁÂÁ½׾Â,ÁÂÁ«e½ú«ü¾É
«á¾ÇÂǦ¹©«¾Ç²ß«e½úªº¤è®×,¾Ç²ß¤ß±oµù¸Ñ¦p¤U,½Ð«e½ú¦A«ü¾É
¸ê®Æªí:
°õ¦æµ²ªG:
¯Ç¤J¦WºÙ:
Sub Âà´«()
Dim Arr, Brr, i&, R&, N&, j%, T1$, T2$
'¡ô«Å§iÅܼÆ:(Arr,Brr)³q¥Î«¬ÅܼÆ,(i,R,N)ªø¾ã¼Æ,jµu¾ã¼Æ,(T1,T2)¦r¦êÅܼÆ
Arr = Sheets("ì©lÀÉ®×").UsedRange
'¡ô¥OArrÅܼƬO¸Ë¤J "ì©lÀÉ®×"¤u§@ªí¦³¨Ï¥ÎÀx¦s®æȪº¤Gºû°}¦C
ReDim Brr(1 To 50000, 1 To 4)
'¡ô«Å§iBrr¬O¤GºûªÅ°}¦C,Áa¦V¯Á¤Þ¸¹(1~500000),¾î¦V¯Á¤Þ¸¹(1~4)
For i = 1 To UBound(Arr)
'¡ô³]¶¶°j°é!i±q1 ¨ìArr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
If Arr(i, 1) = "®Æ¥ó½s¸¹" Then R = i: GoTo i01
'¡ô¦pªGi°j°é¦C1ÄæArr°}¦CȬO "®Æ¥ó½s¸¹"¦r¦ê?
'True´N¥ORÅܼƦPiÅܼÆÈ (³o¬On°O¿ý¨CÓ¬q¸¨ªº¤u§@¯¸¦WºÙ©Ò¦bªº¦C¸¹)
'³Ì«á¸õ¨ì¼Ð¥Ü i01¦ì¸mÄ~Äò°õ¦æ
If Not Arr(i, 4) Like "JM##-#########" Then GoTo i01
'¡ô¦pªGi°j°é¦C4ÄæArr°}¦CȤ£¬O "JM##-#########"³W«hªº¦r¦ê?
'True´N¸õ¨ì¼Ð¥Ü i01¦ì¸mÄ~Äò°õ¦æ
For j = 5 To UBound(Arr, 2)
'¡ô³]¶¶°j°é!j±q5 ¨ìArr°}¦C¾î¦V³Ì¤j¯Á¤ÞÄ渹
If Val(Arr(i, j)) = 0 Then GoTo j01
'¡ô¦pªGi°j°é¦Cj°j°éÄæArr°}¦CÈÂনªº¼ÆȬO 0,´N¸õ¨ì¼Ð¥Ü j01¦ì¸mÄ~Äò°õ¦æ
N = N + 1
'¡ô¥ONÅܼƲ֥[1 (¼g¤J¸ê®Æªº¯Á¤Þ¦C¸¹)
Brr(N, 1) = Arr(i, 1): Brr(N, 2) = Arr(i, 4)
Brr(N, 3) = Arr(R, j): Brr(N, 4) = Arr(i, j)
'¡ô¥OArr°}¦C¸ê®Æ ¼g¤JBrr°}¦C¤¤
j01: Next j
i01: Next i
Call ²M°£: If N = 0 Then Exit Sub
'¡ô°õ¦æ°Æµ{¦¡ Sub ²M°£()
'¦pªGNÅܼƬO0 (¥NªíNÅܼƬO©Ò«Å§iªºªø¾ã¼Æªì©lÈ 0),´Nµ²§ôµ{¦¡°õ¦æ
[Âà´«µ²ªG!A2].Resize(N, 4) = Brr
'¡ô±NBrr°}¦Cȼg¤JÀx¦s®æ¤¤
[Âà´«µ²ªG!A1].Resize(N + 1, 4).Name = "My_Data"
'¡ô¥O«ü©w½d³òÀx¦s®æ¥H "My_Data" ¦r¦ê¬°¦W,¯Ç¤J¦WºÙ¤¤
End Sub
Sub ²M°£()
With Sheets("Âà´«µ²ªG")
If .AutoFilterMode Then .AutoFilterMode = False
'¡ô¦pªG¦³¦Û°Ê¿z¿ï¥\¯à? True´N¥O¿z¿ï¥\¯àÃö³¬
https://learn.microsoft.com/zh-t ... heet.autofiltermode
.UsedRange.Offset(1, 0).EntireRow.Delete
'¡ô¥O°£¤F¼ÐÃD¦C¥H¥~ªº¤w¨Ï¥ÎÀx¦s®æ§R°£
End With
End Sub |
|