How to copy specific worksheets into a new workbook but with values only?

phyxius117

New Member
Joined
May 14, 2024
Messages
6
Office Version
  1. Prefer Not To Say
Platform
  1. Windows
Hello all,

I have figured most of it out myself and after looking around on the internet I still can't figure out a solution to make it value only when saving to a new workbook. I have tested the current code and it works but the new workbooks still have my original formulas in them which is mostly referencing another sheet in the active workbook. I want this new workbook saved as value only.

Here is the current code:

Sub Export()

Dim DCname As String

DCname = ActiveWorkbook.Sheets("Reference").Range("R2").Value

Dim FiscalYear As String

FiscalYear = ActiveWorkbook.Sheets("Reference").Range("R8").Value

Dim Period As String

Period = ActiveWorkbook.Sheets("Reference").Range("R11").Value

Dim FileName As String

FileName = DCname & "_SQL Data_FY" & FiscalYear & "_P" & Period

Worksheets(Array("Route Totals", "Stops")).Copy

ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & FileName, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

End Sub

Thanks for any help I could get!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
One way is to change this
VBA Code:
    Worksheets(Array("Route Totals", "Stops")).Copy

    ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & FileName, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
to this
VBA Code:
    Worksheets(Array("Route Totals", "Stops")).Copy
    
    With ActiveWorkbook.Worksheets("Route Totals")
    .UsedRange.Value = .UsedRange.Value
    End With
    
    With ActiveWorkbook.Worksheets("Stops")
    .UsedRange.Value = .UsedRange.Value
    End With
    
    ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & FileName, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

Tip: For future posts , please try to use code tags like I did above when posting code. It makes your code easier to read and copy.
 
Upvote 0
Thank you!!

Sorry I am new to this forum. Will do for future posts!
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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