|
- Sub demo()
- Dim arr
- arr = Range("a1:b" & Cells(Rows.Count, 1).End(xlUp).Row)
- Dim i&
- Dim objRegExp As Object, obj As Object
- Set objRegExp = CreateObject("VBScript.regExp")
- With objRegExp
- .Global = True
- .Pattern = "(\d{1,2}\.\d{1,2})\-(\d{1,2}\.\d{1,2})"
- For i = 1 To UBound(arr)
- If .test(arr(i, 1)) Then
- Set obj = .Execute(arr(i, 1))
- arr(i, 2) = Format(CDate(Replace(obj(0).submatches(1), ".", "/")), "yyyy-mm-dd") & " " & Format(CDate(Replace(obj(0).submatches(1), ".", "/")), "yyyy-mm-dd")
- End If
- Next
- End With
- Set objRegExp = Nothing
- Range("a1").Resize(UBound(arr), 2).Value = arr
- End Sub
复制代码 |
|