ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet as file (https://www.excelbanter.com/excel-programming/307281-re-worksheet-file.html)

Davor Zupanic

Worksheet as file
 
First of all, thanks!

Just one more question, how to (in SaveWorksheetAsNewWorkbook() ) convert
(format?) all cells as values not formulas with links? Somewhere in this
part of code...?

Thanks

'---------------------------
Private Sub SaveWorksheetAsNewWorkbook()
Dim strSavePath As String
Dim strSaveName As String
strSavePath = "K:\"

Dim wkb As Workbook
With ThisWorkbook.Sheets("Sheet1")
strSaveName = "Name"
strSaveName = strSaveName & _
Format(.Range("A1").Text, "0000")
strSaveName = strSaveName & ".xls"
.Copy
End With
Set wkb = ActiveWorkbook
wkb.SaveAs Filename:= _
strSavePath & strSaveName, _
FileFormat:=xlNormal
wkb.Close
End Sub




Bob Kilmer

Worksheet as file
 
Something like this:

'---------------------------
Private Sub SaveWorksheetAsNewWorkbook()
Dim strSavePath As String
Dim strSaveName As String
strSavePath = "K:\"

Dim wkb As Workbook
With ThisWorkbook.Sheets("Sheet1")
strSaveName = "Name"
strSaveName = strSaveName & _
Format(.Range("A1").Text, "0000")
strSaveName = strSaveName & ".xls"
.Copy
End With
Set wkb = ActiveWorkbook
ActiveSheet.Cells.Copy
ActiveSheet.Cells(1, 1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
ActiveSheet.Cells(1, 1).Select
wkb.SaveAs Filename:= _
strSavePath & strSaveName, _
FileFormat:=xlNormal
wkb.Close
End Sub

Bob Kilmer

"Davor Zupanic" wrote in message
...
First of all, thanks!

Just one more question, how to (in SaveWorksheetAsNewWorkbook() ) convert
(format?) all cells as values not formulas with links? Somewhere in this
part of code...?

Thanks

'---------------------------
Private Sub SaveWorksheetAsNewWorkbook()
Dim strSavePath As String
Dim strSaveName As String
strSavePath = "K:\"

Dim wkb As Workbook
With ThisWorkbook.Sheets("Sheet1")
strSaveName = "Name"
strSaveName = strSaveName & _
Format(.Range("A1").Text, "0000")
strSaveName = strSaveName & ".xls"
.Copy
End With
Set wkb = ActiveWorkbook
wkb.SaveAs Filename:= _
strSavePath & strSaveName, _
FileFormat:=xlNormal
wkb.Close
End Sub







All times are GMT +1. The time now is 03:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com