|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.4.1
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set fso = CreateObject("Scripting.FileSystemObject")
- p = ThisWorkbook.Path & ""
- bt = [{"JS","ZS","QL","C1","C2","C3","NC4","IC4","NC5","IC5"}]
- On Error Resume Next
- For Each f In fso.GetFolder(p).Files
- If f.Name Like "*.xlsx" Then
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- d.RemoveAll
- arr = wb.Sheets(1).UsedRange
- ReDim brr(1 To 10000, 1 To UBound(bt))
- wb.Close False
- Set wb = Workbooks.Add
- Set sht = wb.Sheets(1)
- m = 0
- With sht
- .[a1].Resize(1, UBound(bt)) = bt
- For j = 1 To UBound(bt)
- d(bt(j)) = j
- Next
- For i = 2 To UBound(arr)
- m = m + 1
- For j = 1 To UBound(arr, 2)
- s = arr(1, j)
- brr(m, d(s)) = arr(i, j)
- Next
- Next
- .[a2].Resize(m, UBound(bt)) = brr
- End With
- mFile = p & fn & ".txt"
- wb.SaveAs Filename:=mFile, FileFormat:=xlText, CreateBackup:=True
- wb.Close 1
- End If
- End If
- Next f
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|