返回列表 上一主題 發帖

[發問] 求助 split問題 感恩

  1. Sub SplitText()
  2.   Dim I       As Long, J As Long
  3.   Dim RegExp  As Object
  4.   Dim Match   As Object
  5.   Dim strNum  As String
  6.   Dim strValue  As String
  7.   
  8.   Set RegExp = CreateObject("VBScript.RegExp")
  9.   With Sheet2
  10.     With RegExp
  11.       .Global = True
  12.       .Pattern = "\d+"
  13.     End With
  14.     For I = 2 To .Cells(.Rows.Count, 1).End(xlUp).Row
  15.       strValue = .Cells(I, 1).Value
  16.       Set Match = RegExp.Execute(strValue)
  17.       If Match.Count Then
  18.         strNum = Match.Item(0)
  19.         .Cells(I, 2).Value = strNum
  20.         J = InStr(strValue, strNum) + Len(strNum)
  21.         If J Then .Cells(I, 3).Value = Mid$(strValue, J)
  22.         Set Match = Nothing
  23.       Else
  24.         .Cells(I, 3).Value = strValue
  25.       End If
  26.     Next I
  27.   End With
  28. End Sub
複製代碼
世界那麼大,可我想去哪?

TOP

        靜思自在 : 閒人無樂趣,忙人無是非。
返回列表 上一主題