|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf2() '//2025.1.15
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- p = ThisWorkbook.Path & "\txt文件"
- Set sh = ThisWorkbook.Sheets("测试")
- ReDim brr(1 To 10000, 1 To 100)
- num = 10000
- On Error Resume Next
- Dim tm: tm = Timer
- For Each f In fso.GetFolder(p).Files
- If f.Name Like "*.txt" Then
- Set wb = Workbooks.Open(f, 0)
- m = m + 1
- brr(m, 1) = m
- brr(m, 2) = f.Name
- With wb.Sheets(1)
- r = .UsedRange.Find("1.0 Purpose").Row
- arr = .UsedRange.Offset(r - 1).Value
- st = .Cells(r, 1).Value
- End With
- wb.Close 0
- For i = 2 To UBound(arr)
- st = st & arr(i, 1)
- Next
- k = Application.Ceiling(Len(st) / num, 1)
- For x = 1 To k
- If x = k Then
- brr(m, x + 2) = Mid(st, (k - 1) * num + 1)
- Else
- brr(m, x + 2) = Mid(st, (x - 1) * num + 1, num)
- End If
- Next
- Max = IIf(Max < k, k, Max)
- End If
- Next
- With sh
- .UsedRange.Offset(1).Clear
- .[a2].Resize(m, Max + 2) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|