|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
代码已更新。。。
- Sub ykcbf() '//2024.4.12
- Application.ScreenUpdating = False
- Set fso = CreateObject("scripting.filesystemobject")
- Set sh = ThisWorkbook.Sheets("Sheet1")
- p = ThisWorkbook.Path & ""
- ReDim brr(1 To 50000, 1 To 15)
- On Error Resume Next
- For Each f In fso.GetFolder(p).Files
- If LCase(f.Name) Like "*.txt" Then
- fn = fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- zrr = .UsedRange
- wb.Close
- End With
- For i = 5 To UBound(zrr)
- st = WorksheetFunction.Trim(zrr(i, 1))
- If InStr(zrr(i, 1), "|--") = 0 Then
- b = Split(zrr(i, 1), "|")
- If b(2) <> Empty And InStr(b(4), "TO Number") = 0 Then
- m = m + 1
- For x = 1 To 15
- brr(m, x) = Trim(b(x))
- Next
- End If
- st = Replace(brr(m, 9), ".", "-")
- brr(m, 9) = IIf(Left(st, 2) = "00", "", Format(st, "yyyy/m/d"))
- st = Replace(brr(m, 12), ".", "-")
- brr(m, 12) = IIf(Left(st, 2) = "00", "", Format(st, "yyyy/m/d"))
- brr(m, 13) = IIf(Left(CDate(brr(m, 13)), 2) = "0:", "", brr(m, 13))
- brr(m, 14) = IIf(Left(CDate(brr(m, 14)), 2) = "0:", "", brr(m, 14))
- End If
- Next
- End If
- Next f
- With sh
- .UsedRange.Offset(1).Clear
- .Columns("a:g").NumberFormatLocal = "@"
- .Columns(8).NumberFormatLocal = "0"
- .[a2].Resize(m, 15) = brr
- .[a2].Resize(m, 15).Borders.LineStyle = 1
- .[a2].Resize(m, 15).Sort .[o2], 2
- r1 = .Cells(Rows.Count, 2).End(3).Row
- For i = r1 To 2 Step -1
- If .Cells(i, 2).Value <> Empty Then Exit For
- r = i - 1
- Next
- .UsedRange.Offset(r).Clear
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|