No need to add a workbook and copy the sheets in it
You can use
Sub Copy_test()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
Sheets(Array("Bestellijst", "Gegevensblad")).Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "C:\Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
.Close False
End With
Application.ScreenUpdating = True
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl
"eyesonly1965" wrote in message
news:eyesonly1965.27szvm_1147620301.5025@excelforu m-nospam.com...
i have read the code you provided and combined it with my own code.
it looks like this:
Private Sub cmdOpslaan_Click()
'variabelen declareren
Dim fname As String
Dim newWB As Workbook
Dim wb As Worksheet
'naam genereren met code voor besteller en bestelnummer
fname = Range("A4").Value & " - " & Range("B4").Value & ".xls"
'nieuwe workbook aanmaken
Set newWB = Workbooks.Add
'sheets kopieren: bestellijst en gegevensblad moeten worden
gekopieerd
'om te voorkomen dat de gegevens niet meer bestaan, dit omdat
'de orginele bestellijst leeg wordt gemaakt om weer een nieuwe te
kunnen
'maken.
ThisWorkbook.Worksheets("Bestellijst").Copy
Befo=newWB.Worksheets(1)
ThisWorkbook.Worksheets("Gegevensblad").Copy
Befo=newWB.Worksheets(2)
'nieuwe workbook opslaan onder de nieuwe naam
newWB.SaveAs Filename:=fname
End Sub
i discovered that that when i saved more new files they all showed the
same data, this because it looked in the original workbook for the data
in gegevensblad.
so i needed to copy that sheet also into the new workbook.
anyway i thank for pointing me in the right direction.:)
--
eyesonly1965
------------------------------------------------------------------------
eyesonly1965's Profile: http://www.excelforum.com/member.php...o&userid=34199
View this thread: http://www.excelforum.com/showthread...hreadid=541805