|
楼主 |
发表于 2018-9-26 22:22
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我就奇了怪了,我感觉没有错了,怎么运行会有变量未定义的提示呢,以下是我照您的代码打的呀,麻烦您看看有没有错的地方:
Sub test()
Dim wbk As Workbook, mypath$, fn, sht As Worksheet
Dim nwbk As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
mypath = ThisWorkbook.Path & "\"
fn = Dir(mypath & "*.xl*")
Do While fn <> ""
If fn <> ThisWorkbook.Name Then
Set wbk = Workbooks.Open(mypath & fn)
Set sht = wbk.Sheets("岁段名册总表")
sht nwbk = ActiveWorkbook
nwbk.SaveAs Left(wbk.Name, Len(wbk.Name) - 4) & sht.Name
nwbk.Close False
wbk.Close False
End If
fn = Dir
Loop
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
|