|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Set reg = CreateObject("vbscript.regexp")
- reg.Global = True
- reg.Pattern = "((20|19)?\d\d).?(1[0-2]|0?[1-9])?.?(3[01]|[12]\d|0?[1-9])?"
- ar = [a1:a103]
- For i = 1 To UBound(ar)
- '正则替换,去首尾空格并拆分
- s = Split(Trim(reg.Replace(ar(i, 1), "$1 $3 $4")))
- n = UBound(s)
- If n = 2 Then t = Join(s, "/") '年月日齐全处理
- If n = 1 Then t = Join(s, "/") & "/1" '缺日处理
- If n = 0 Then t = s(0) & "/1/1" '缺月日处理
- ar(i, 1) = IIf(Len(s(0)) = 2, 19 & t, t) '二位年份补四位
- Next
- [b1].Resize(UBound(ar), 1) = ar
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|