|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
按1楼题意重写一个。。。
- Sub ykcbf() '//2024.12.7
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- Dim tm: tm = Timer
- Set ws = ThisWorkbook
- Set sh = ws.Sheets("操作台")
- For Each sht In Sheets
- If sht.Name <> sh.Name Then sht.Delete
- Next
- p = ThisWorkbook.Path & ""
- For Each f In fso.GetFolder(p).Files
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = fso.GetBaseName(f)
- fn = Left(fn, 1) & "(" & ston(fn) & ")班"
- Set wb = Workbooks.Open(f, 0)
- wb.Sheets(1).Copy After:=ws.Sheets(ws.Sheets.Count)
- Set sht = ws.Sheets(ws.Sheets.Count)
- sht.Name = fn
- wb.Close 0
- End If
- Next f
- sh.Activate
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
- Function ston(str) As String
- Dim reg As Object
- Set reg = CreateObject("VBScript.RegExp")
- With reg
- .Pattern = "[^\d]+"
- .Global = True
- .IgnoreCase = True
- End With
- ston = reg.Replace(str, "")
- Set reg = Nothing
- End Function
复制代码
|
|