ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¨D§U split°ÝÃD ·P®¦

  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
½Æ»s¥N½X
¥@¬É¨º»ò¤j¡A¥i§Ú·Q¥h­þ¡H

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¤Hªº§Ö¼Ö¡D¤£¬O¦]¬°¥L¾Ö¦³±o¦h¡A¦Ó¬O¦]¬°¥L­p¸û±o¤Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD