Option Explicit
Sub TEST()
Dim Fn, Rg, Brr, Crr, i&, j&, Sh
Set Sh = ActiveSheet
Brr = Range(Sh.[A1], Sh.[A65536].End(3))
Set Rg = CreateObject("VBScript.RegExp")
Rg.Pattern = "\d+"
Rg.Global = True
ReDim Crr(1 To UBound(Brr), 0) As String
For i = 1 To UBound(Brr)
Set Fn = Rg.Execute(Brr(i, 1))
If Fn.Count > 0 Then
For j = 0 To Fn.Count - 1 '請教各位前輩,可以用Join取代這迴圈嗎?
Crr(i, 0) = Crr(i, 0) & Fn(j)
Next
End If
Next
Sh.[D1].Resize(UBound(Brr), 1) = Crr
End Sub
'以下是測試一維陣列Join
Sub 一維陣列Join()
Dim T
T = [{1,2,3,4,5,6}]
MsgBox T(1)
MsgBox Join(T)
End Sub作者: Andy2483 時間: 2022-12-27 15:01