View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Copying worksheet to new file by macro

Hi Ruatha

Sub test()
Dim wb As Workbook
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb.Sheets(1)
.UsedRange.Copy
.UsedRange.PasteSpecial xlPasteValues
.Cells(1).Select
Application.CutCopyMode = False
End With
wb.SaveAs "C:\" & wb.Sheets(1).Name & ".xls"
wb.Close False
End Sub


This example will create a workbook for every sheet
http://www.rondebruin.nl/copy6.htm


--
Regards Ron De Bruin
http://www.rondebruin.nl



"Ruatha" wrote in message
...

Hi.
By pressing a commandbutton, I want to copy a worksheet (The content,
not the functions) into a new file.
There are 52 worksheets called "Vecka 1" to "Vecka 52".
The user enters a number in a cell and presses a command button next to
that cell, and then the worksheet with the number the user has given
should be copied to a file called "Vecka xx.xls" where xls is the
number of the worksheet." (Vecka 0-52).

How to do that?


--
Ruatha
------------------------------------------------------------------------
Ruatha's Profile: http://www.excelforum.com/member.php...o&userid=31083
View this thread: http://www.excelforum.com/showthread...hreadid=550773