Macro to export worksheets as xlsm with Values not Formulas

jpsimmon

New Member
Joined
Apr 9, 2015
Messages
28
I am using the below code at the end of my mod to copy and export my workbook without it's formulas and macros. Seems to work well, but if I want to exclude a couple of worksheets from the file that it exports, what do I need to add?

Code:
    Dim Output As Workbook
    Dim Current As String
    Dim FileName As String


    Set Output = ThisWorkbook
    Current = ThisWorkbook.FullName


    Application.DisplayAlerts = False


    Dim SH As Worksheet
    For Each SH In Output.Worksheets


        SH.UsedRange.Copy
        SH.UsedRange.PasteSpecial xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=True, Transpose:=False


    Next


    FileName = ThisWorkbook.Path & "S:\Location\" & "air.xlsx"
      Output.SaveAs FileName:="S:\Location\air.xlsx", _
                FileFormat:=xlOpenXMLWorkbook
    'Workbooks.Open Current
    'Output.Close
    Application.DisplayAlerts = True


End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,216,069
Messages
6,128,608
Members
449,460
Latest member
jgharbawi

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