|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 ykcbf1100 于 2024-4-19 11:23 编辑
参与一下。。。
- Sub ykcbf() '//2024.4.19
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set reg = CreateObject("VBScript.Regexp")
- With Sheets("原表")
- r = .Cells(Rows.Count, 1).End(3).Row
- .UsedRange.Offset(r).Clear
- arr = .[a1].Resize(r, 8)
- End With
- b = [{1,8,7,2,3,4,5,6}]
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2) + 1)
- On Error Resume Next
- With reg
- .Global = True
- .Pattern = "(\d+)"
- For i = 2 To UBound(arr)
- If arr(i, 1) <> Empty Then
- m = m + 1
- For j = 1 To UBound(b)
- brr(m, j) = arr(i, b(j))
- Next
- rq = CStr(arr(i, 2))
- brr(m, 4) = Left(rq, 4) & "/" & Mid(rq, 5, 2) & "/" & Mid(rq, 7, 2)
- sj = CStr(arr(i, 3))
- brr(m, 5) = IIf(sj = "", "", Left(sj, 2) & ":" & Mid(sj, 3, 2))
- st = arr(i, b(8))
- If st = "短信费" Then brr(m, 8) = "": brr(m, 9) = "短信费"
- If st = "/" Then brr(m, 8) = "": brr(m, 9) = ""
- If InStr(st, "/") Then
- brr(m, 8) = Split(st, "/")(0): brr(m, 9) = Split(st, "/")(1)
- Else
- Set mh = .Execute(st)
- brr(m, 8) = CStr(mh(0).Value)
- brr(m, 9) = Replace(st, brr(m, 8), "")
- End If
- End If
- Next
- End With
- With Sheets("生成新表")
- .[a1].Resize(1, 9).Interior.Color = 49407
- .UsedRange.Offset(1) = ""
- .Columns("A:e,h:i").NumberFormatLocal = "@"
- .Columns(4).NumberFormatLocal = "yyyy/m/d"
- With .[a2].Resize(m, 9)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|