|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub g()
Set reg = CreateObject("vbscript.regexp")
Dim rng As Range
reg.Global = True
reg.Pattern = "\d+"
For Each rng In Range(Cells(5, 1), Cells(Rows.Count, 1).End(3))
Set k = reg.Execute(rng)
If k.Count = 2 Then
rng.Offset(, 1) = DateSerial(k(0), k(1), 1)
ElseIf k.Count = 3 Then
rng.Offset(, 1) = DateSerial(k(0), k(1), k(2))
ElseIf k.Count = 1 Then
rng.Offset(, 1) = DateSerial(Left(k(0), 4), Mid(k(0), 5, 2), Mid(k(0), 7, 2))
End If
Next rng
End Sub |
|