- ©«¤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
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-6-1 08:53 ½s¿è
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ßVBA°}¦C,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim Brr, Crr, A, i&, j%, M%
'¡ô«Å§iÅܼÆ
Brr = Range([A2], [A65536].End(3))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥HAÄæÀx¦s®æȱa¤J
ReDim Crr(1 To UBound(Brr), 1 To 100)
'¡ô¥OCrrÅܼƬO ¤GºûªÅ°}¦C,Áa¦V½d³ò¦PBrr°}¦C,¾î¦V1~100
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!³v¦C°õ¦æ
If InStr(Brr(i, 1), "fee$") = 0 Then GoTo i01 Else: A = Split(Brr(i, 1), "fee$")
'¡ô¦pªGBrr°}¦CȤ£¥]§t "fee$"´N¸õ¨ì¼Ð¥Üi01¦ì¸mÄ~Äò°õ¦æ,
'§_«h´N¥OAÅܼƬO ¤@ºû°}¦C,¥H"fee$" ¤À³ÎBrr°}¦Cȱa¤JA°}¦C¸Ì
If M < UBound(A) Then M = UBound(A)
'¡ô¦pªGMÅܼƤp©óA°}¦Cªº³Ì¤j¯Á¤Þ¸¹,´N¥OMÅܼƬO A°}¦Cªº³Ì¤j¯Á¤Þ¸¹
For j = 1 To UBound(A): Crr(i, j) = Val(A(j)): Next
'¡ô³]¶¶°j°é!±NA°}¦CÈÂà¤Æ¬°¼ÆÈ«á¼g¤JCrr°}¦C¸Ì
i01: Next
[B2].Resize(UBound(Brr), M) = Crr
'¡ô¥OCrr°}¦Cȱq[B2]¶}©l¼g¤J¦J¦CªºÀx¦s®æ¤¤,¶W¹L½d³òªº°}¦CÈ©¿²¤
Erase Brr, Crr, A
'¡ô¥OÄÀ©ñÅܼÆ
End Sub
'==================================================
'¸É¥R:¥H¤U¥t¤@ºØ±¡ªp
Sub TEST_1()
Dim Brr, Crr, A, i&, j%, M%
Brr = Range([A2], [A65536].End(3))
ReDim Crr(1 To UBound(Brr), 1 To 100)
For i = 1 To UBound(Brr)
If InStr(Brr(i, 1), "fee") = 0 Then GoTo i01 Else: A = Split(Brr(i, 1), "fee")
If M < UBound(A) Then M = UBound(A)
For j = 1 To UBound(A): Crr(i, j) = Val(Replace(A(j), "$", "")): Next
i01: Next
[B2].Resize(UBound(Brr), M) = Crr
Erase Brr, Crr, A
End Sub |
|