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
 
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.
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Glad it's sorted & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

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