- ©«¤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# Andy2483
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾Ç½Æ²ß³o©«¤è®×,¾Ç²ß¤ß±oµù¸Ñ¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
Option Explicit
Sub TEST()
Dim Brr, Crr, i&, Q$, X$, T$, P$, Y$, Jm%, j%
'¡ô(Brr,Crr)¬O³q¥Î«¬ÅܼÆ,i¬Oªø¾ã¼Æ,(Q,X,T,P,Y)¬O¦r¦êÅܼÆ,(Jm,j)¬Oµu¾ã¼Æ
Brr = Range([A2], Cells(Rows.Count, "A").End(3))
'¡ô¥OBrr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,¥H[A2]¨ìAÄæ³Ì«á¤@Ó¦³¤º®eÀx¦s®æȱa¤J
ReDim Crr(1 To UBound(Brr), 1 To 2)
'¡ô«Å§iCrrÅܼƬO¤Gºû°}¦C,Áa¦V½d³ò±q1¨ì Brr°}¦CÁa¦V¯Á¤Þ¦C¸¹,
'¾î¦V½d³ò±q1¨ì 2
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!i±q1¨ì Brr°}¦CÁa¦V¯Á¤Þ¦C¸¹
Q = Trim(Brr(i, 1))
'¡ô¥OQ³o¦r¦êÅܼƬO i°j°é¦C²Ä1ÄæBrr°}¦CÈ¥h°£ÀY§ÀªÅ¦r¤¸«áªº·s¦r¦ê
For j = 1 To Len(Q)
'¡ô³]¶¶°j°é!j±q1¨ì Q¦r¦ê¦r¤¸¼Æ
T = Mid(Q, j, 1)
'¡ô¥OT³o¦r¦êÅܼƬOQÅܼƨújÅܼƶ}©lªº1Ó¦r
If T <> Evaluate("LeftB(""" & T & """,1)") Then Jm = Jm + 1: P = P & T
'¡ô¦pªGTÅܼƻP TÅܼƨú1Ӧ줸¦^¶ÇȤ£¬Û¦P!´N¥OJm³oµu¾ã¼Æ²Ö¥[1,
'¥OP³o¦r¦êÅܼƬO¦Û¨³s±µTÅܼƩҲզ¨ªº·s¦r¦ê (PS:°ê¦r¬OÂù¦ì¤¸²Õ¦¨ªº¦r¤¸)
Next
P = Switch(Jm > 0, P, Q Like "[A-Z]*######GP##", Right(Q, 10), P = P, "")
'¡ô¥OPÅܼƬOSwitch ¨ç¼Æ¦^¶ÇÈ,
'¦pªG¦³Âù¦ì¤¸ªº¦r¤¸,´N¦^¶ÇP¬O¦Û¨È
'¦pªGQ¦r¦êªº²Õ¦X¬O^¤å¦r¶}ÀY,¦A³s±µ6Ó(§t)¥H¤W¼Æ¦r¦r¤¸,Äò³s±µ"GP"¦r¤¸,
'³Ì«á³s±µ¨âӼƦr¦r¤¸,´N¦^¶ÇP¬OQ¦r¦êªº¥kÃä10Ó¦r¤¸
'¦pªG«e±¨âÓ§PÂ_³£¤£¦¨¥ß!´N¦^¶ÇP¬OªÅ¦r¤¸
Y = IIf(P = "", "µL", P): P = Replace(Q, P, "")
'¡ô¥OY³o¦r¦êÅܼƬOIIf¨ç¼Æ¦^¶ÇÈ,
'¦pªGPÅܼƬO ªÅ¦r¤¸,´N¦^¶ÇY¬O "µL"¦r¤¸,§_«h´N¦^¶ÇY¬O PÅܼÆÈ,
'¥OPÅܼƬOQÅܼƱN©Ò§tªºPÅܼÆȸm´«¬°ªÅ¦r¤¸
X = IIf(P = "", "µL", P): Crr(i, 1) = X: Crr(i, 2) = Y
'¡ô¥OX³o¦r¦êÅܼƬOIIf¨ç¼Æ¦^¶ÇÈ,
'¦pªGPÅܼƬO ªÅ¦r¤¸,´N¦^¶ÇX¬O "µL"¦r¤¸,§_«h´N¦^¶ÇX¬O PÅܼÆÈ,
'¥Oi°j°é¦C²Ä1ÄæCrr°}¦CȬO XÅܼÆÈ
'¥Oi°j°é¦C²Ä2ÄæCrr°}¦CȬO YÅܼÆÈ
P = "": Jm = 0
'¡ô¥OPÅܼƬO ªÅ¦r¤¸,¥OJmÅܼÆÂk¹s
Next
Intersect(ActiveSheet.UsedRange.Offset(1, 0), [X:Y]).ClearContents
'¡ô¥O¨â°ÏÀx¦s®æ¬Û¥æ¶°ªºÀx¦s®æ²M°£¤º®e
'²Ä¤@°Ï:¥»ªí¦³¨Ï¥ÎªºÀx¦s®æ¦V¤U°¾²¾¤@¦Cªº½d³òÀx¦s®æ
'¥t¤@°Ï:¥»ªíªºX:YÄæÀx¦s®æ
[X2].Resize(UBound(Crr), 2) = Crr
'¡ô¥O[X2]ÂX®i¦V¤UCrr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹,¦V¥kÂX®i2Äæ,
'³o½d³òÀx¦s®æÈ¥HCrr°}¦Cȱa¤J
Erase Brr, Crr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|