|
发表于 2013-1-27 01:15
|
显示全部楼层
本楼为最佳答案
- Option Explicit
- Sub 提取数据()
- Dim arr, result(), temp As Object, k&, i&, j&
- Dim iRow&
- iRow = Cells(Rows.Count, 1).End(xlUp).Row
- arr = Range("a1:a" & iRow)
- ReDim result(1 To iRow, 1 To 3)
- Dim reg As Object
- Set reg = CreateObject("VBScript.regExp")
- With reg
- .Global = True
- .Pattern = "(\d+)/(\d+)/(\d+)"
- For i = 1 To UBound(arr)
- If .test(arr(i, 1)) Then
- k = k + 1
- Set temp = .Execute(arr(i, 1))
- For j = 1 To UBound(result, 2)
- result(k, j) = "'" & temp(0).Submatches(j - 1)
- Next
- End If
- Next
- End With
- Range("e1").Resize(k, 3) = result
- Set reg = Nothing
- MsgBox "提取完成"
- End Sub
复制代码 |
|