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
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