Exporting Worksheets as xlsm with Values not Formulas

jpsimmon

New Member
Joined
Apr 9, 2015
Messages
28
I am using an export code to take my worksheets to a destined folder in xlsm format. I am looking to adjust this formula so when the worksheets are exported it is a flat file that just contains the values in the cells NOT the formulas.

Code:
Sub CreateWorkbooks()Dim wbDest As Workbook
Dim wbSource As Workbook
Dim sht As Object 
Dim strSavePath As String


On Error GoTo ErrorHandler


Application.ScreenUpdating = False 


strSavePath = "S:\Test\" 


Set wbSource = ActiveWorkbook


For Each sht In wbSource.Sheets
sht.Copy
Set wbDest = ActiveWorkbook
wbDest.SaveAs strSavePath & sht.Name
wbDest.Close 
Next


Application.ScreenUpdating = True


Exit Sub


ErrorHandler: 
MsgBox "An error has occurred. Error number=" & Err.Number & ". Error description=" & Err.Description & "."
End Sub

Thanks for the help
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
you might want to consider copy and paste your data as values, just be sure you don't overwrite your live file
 
Upvote 0
Code:
    Range("A1:Z1000").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
 
Upvote 0
It still transfers the formulas to the exports, not just the values

Code:
Sub CreateWorkbooks()Dim wbDest As Workbook
Dim wbSource As Workbook
Dim sht As Object
Dim strSavePath As String

On Error GoTo ErrorHandler

Application.ScreenUpdating = False

strSavePath = "S:\Test\"

Set wbSource = ActiveWorkbook

For Each sht In wbSource.Sheets
    Range("G1:W645").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
sht.Copy

Set wbDest = ActiveWorkbook
wbDest.SaveAs strSavePath & sht.Name
wbDest.Close
Next

Application.ScreenUpdating = True

Exit Sub

ErrorHandler:
MsgBox "An error has occurred. Error number=" & Err.Number & ". Error description=" & Err.Description & "."
End Sub
 
Upvote 0
before sht.copy, break the code and see whats stored in the formula cells
 
Upvote 0

Forum statistics

Threads
1,217,466
Messages
6,136,836
Members
450,027
Latest member
Apexwolf

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top