copy and save excel worksheet without formulas

primep

New Member
Joined
May 29, 2020
Messages
10
Office Version
  1. 2013
Platform
  1. Windows
I want to copy and save a worksheet "Template", below VBA is working good, but it is copying also the formulas, I want only cell values of above work to be copied and saved.

Thanks

Private Sub CommandButton1_Click() ' Save Excel Copy

Dim FileName As String

Dim FilePath As String

Dim NewBook As Workbook

FilePath = "D:\"

FileName = Sheets("Template").Range("g14") & ".xls"

If Dir(FilePath & "\" & FileName) <> "" Then

MsgBox "File " & FilePath & "\" & FileName & " already exists", vbInformation

Exit Sub

Else

Set NewBook = Workbooks.Add

ThisWorkbook.Sheets("Template").Copy before:=NewBook.Sheets(1)

Application.DisplayAlerts = False

NewBook.SaveAs FileName:=FilePath & FileName

NewBook.Activate

On Error Resume Next

ActiveSheet.OLEObjects.Visible = True

ActiveSheet.OLEObjects.Delete

On Error GoTo 0

NewBook.Save

NewBook.Close

End If

End Sub
 

primep

New Member
Joined
May 29, 2020
Messages
10
Office Version
  1. 2013
Platform
  1. Windows
Hi Fluff,
There was confusion from my side, you edited code is really working fine,
My problem is solved
I appreciate thank you very much.
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,412
Office Version
  1. 365
Platform
  1. Windows
Glad it's sorted & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,328
Messages
5,624,034
Members
416,007
Latest member
csf

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
Top