我有一个代码,可以从工作簿中提取选项卡并将该选项卡另存为单独的工作表。除了将公式也提取到新工作表的事实之外,一切对我来说都很好。如何更改下面提到的代码以相同的格式保存工作表,但是没有任何公式?
Sub PrintFile2()
'check if folder exists
If Dir("C:\Excel Workpaper\", vbDirectory) = "" Then
MkDir "C:\Excel Workpaper\"
End If
'print to defined folder
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim wb As Workbook
Sheets("Calculations").Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "C:\Excel Workpaper\ " & Range("B7").Text & " - Excel Workpaper",
FileFormat:=xlOpenXMLWorkbook
Application.DisplayAlerts = False
Application.ScreenUpdating = True
.Close False
End With
End Sub
答案 0 :(得分:1)
选中此代码段,此代码会将公式更改为值。
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.Select
With sh.UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
Next sh