|
Sub 导出到新工作薄()
Application.ScreenUpdating = False
Dim arr, wb As Workbook, key, dz, dzz
dzz = Cells(4, 12)
key = InputBox("请输入文件名", "某某公司名称", dzz)
If Len(key) > 0 And key <> "" Then
dz = "\" & key & ".xls"
With Sheet5
arr = .UsedRange
End With
Set wb = Workbooks.Add
With wb
With .Sheets(1) '目标表名不能更改
.Range("a1").Resize(UBound(arr), UBound(arr, 2) - 4) = arr '-4为最尾列减4列的意思
.Application.DisplayAlerts = False '直接覆盖不提示
End With
.SaveAs ThisWorkbook.Path & dz
.Close
End With
Set wb = Nothing
Application.ScreenUpdating = True
Else
End If
MsgBox "文件导出成功!文件名为:" & dz & ""
End Sub |
|