|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 全过程预算书导出()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.DisplayAlerts = 0 '不提示保存本工作表
Dim lj As String
Dim nm As String
Dim dirname As String
lj = ActiveWorkbook.Path
nm = ActiveWorkbook.Name
n = 0
dirname = Dir(lj & "/*.xls*")
Do While dirname <> ""
If dirname <> nm Then
n = n + 1
Workbooks.Open Filename:=lj & "\" & dirname
Sheets("项目信息").Visible = True
Sheets("甲供材格式清单").Visible = True
Sheets("拆旧材料格式清单").Visible = True
filesavename = Sheets("封面").Range("D3")
ipath = ThisWorkbook.Path & "\"
For Each sht In ActiveWindow.SelectedSheets
sht = Sheets("项目信息").Copy
Sheets("项目信息").UsedRange.Value = ActiveSheet.UsedRange.Value
Sheets("甲供材格式清单").Copy
Sheets("甲供材格式清单").UsedRange.Value = ActiveSheet.UsedRange.Value '到这里提至下标越界错误
Sheets("拆旧材料格式清单").Copy
Sheets("拆旧材料格式清单").UsedRange.Value = ActiveSheet.UsedRange.Value
thename = filesavename & "_预算书"
ActiveWorkbook.SaveAs ipath & thename & ".xlsx"
ActiveWindow.Close
Next
Workbooks(dirname).Close False
End If
dirname = Dir
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "本次总计生成了: " & n & " 预算书"
End Sub
请大神帮忙指正,谢谢。
|
|