![]() |
Copying worksheet to new file by macro
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 |
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 |
Copying worksheet to new file by macro
Thanx. It works good and makes a file for the active worksheet, now I'll try to adapt it to my needs! Thanx again Ron de Bruin -- Ruatha ------------------------------------------------------------------------ Ruatha's Profile: http://www.excelforum.com/member.php...o&userid=31083 View this thread: http://www.excelforum.com/showthread...hreadid=550773 |
All times are GMT +1. The time now is 09:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com