Z9z9z9
Z9z9z9

Reputation: 71

Save worksheet values to another workbook

I have a code that could save a specific worksheet where you can pick its file name and path. The problem is it also copies the formulas when the new file is saved. I need to copy only the values, because the file is too big and I don't need the formulas in the new save, just the values.

Here's the code:

Dim wb As Workbook, InitFileName As String, fileSaveName As String

InitFileName = ThisWorkbook.Path & "\ - Recon_Output_ " & Format(Date, "yyyymmdd")

Sheets("Source").Copy

Set wb = ActiveWorkbook

fileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitFileName, _
FileFilter:="Excel files , *.xlsx")

With wb
    If fileSaveName <> "False" Then

        .SaveAs fileSaveName
        .Close
    Else
        .Close False
        Exit Sub
    End If
End With

Any suggestions will be appreciated. Thank you!

Upvotes: 1

Views: 336

Answers (1)

Abe Gold
Abe Gold

Reputation: 2347

After:

Set wb = ActiveWorkbook

Add in:

tempArr = wb.Sheets("Source").UsedRange
wb.Sheets("Source").UsedRange = tempArr

Upvotes: 1

Related Questions