Rickinnocal
New Member
- Joined
- Dec 14, 2010
- Messages
- 33
- Office Version
- 365
- Platform
- Windows
Hello, I have a workbook with several sheets. One of the sheets is a summary, the format and layout of which is from the customer. I need to send my customer this summary as a one page workbook.
I've copied the customers form into my workbook, and have it all set up to populate and calculate properly. Now I want a command button that will copy the sheet to a new workbook.
1st problem... I seem to be stuck, though, with either cells in the new workbook still containing formulas referring back to the original workbook, not just the data, or they contain data only but the formatting all vanishes.
This is my latest attempt...
If I don't use xlPasteValues I can get the formatting, but it copies formulas.
My second issue is that I get this error message....
The file name is different every time I do it, and I don't know where its coming from.
Any hints, please?
Richard
I've copied the customers form into my workbook, and have it all set up to populate and calculate properly. Now I want a command button that will copy the sheet to a new workbook.
1st problem... I seem to be stuck, though, with either cells in the new workbook still containing formulas referring back to the original workbook, not just the data, or they contain data only but the formatting all vanishes.
This is my latest attempt...
VBA Code:
Private Sub cmdMakeBQS_Click()
Dim wsCopy As Worksheet, wsPaste As Worksheet
Dim wb As Workbook
Dim sFileName As String, sPath As String
'Path to store new file
sPath = "C:\"
'Change filename as required
sFileName = "New BQS"
'set the sheet you are copying. Change where neccessary
Set wsCopy = ThisWorkbook.Worksheets("Prelim (FO)")
Set wb = Workbooks.Add
Set wsPaste = wb.Sheets(1)
'Copy everything from copy sheet
wsCopy.Cells.Copy
'Paste Values only
wsPaste.Cells.PasteSpecial xlPasteValues
Application.CutCopyMode = False
'Save new workbook
wsPaste.Name = "New BQS" 'Change if needed
wb.SaveAs Filename:=sPath & sFileName, FileFormat:=xlOpenXMLWorkbook
End Sub
If I don't use xlPasteValues I can get the formatting, but it copies formulas.
My second issue is that I get this error message....
The file name is different every time I do it, and I don't know where its coming from.
Any hints, please?
Richard