Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, I am trying to create a script that will create a new uniquely named workbook with time and date, and copy several of the worksheets from my original workbook into the new workbook. I have got the code below which works for the activesheet but how would I get it to do it for several specified sheets? I will use this script in several models and so I can't specify the workbook name and keep switching between workbooks to copy them. Any help would be great! Thanks Code: -------------------- Sub Create_Factbase() Dim FileName As String Application.ScreenUpdating = False FileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) ActiveSheet.Cells.Copy Workbooks.Add Selection.PasteSpecial Paste:=xlValues Selection.PasteSpecial Paste:=xlFormats ActiveWorkbook.SaveAs FileName:=FileName + "_" + Format(Date, "dd-mm-yy") + _ "_" + Format(Time, "hh-mm-ss") ActiveSheet.Range("a1").Select Application.ScreenUpdating = True End Sub -------------------- -- soteman2005 ------------------------------------------------------------------------ soteman2005's Profile: http://www.excelforum.com/member.php...o&userid=29078 View this thread: http://www.excelforum.com/showthread...hreadid=493040 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Create_Factbase1()
Dim sh as Worksheet Dim FileName as String FileName = "something" worksheest(Array("Data","Sales","Earnings")).copy for each sh in activeWorkbook sh.cells.copy sh.cells.pastespecial paste:=xlValues Next ActiveWorkbook.SaveAs FileName:=FileName + "_" + Format(Date, "dd-mm-yy") + _ "_" + Format(Time, "hh-mm-ss") ActiveSheet.Range("a1").Select Application.ScreenUpdating = True End Sub -- Regards, Tom Ogilvy "soteman2005" wrote in message ... Hi, I am trying to create a script that will create a new uniquely named workbook with time and date, and copy several of the worksheets from my original workbook into the new workbook. I have got the code below which works for the activesheet but how would I get it to do it for several specified sheets? I will use this script in several models and so I can't specify the workbook name and keep switching between workbooks to copy them. Any help would be great! Thanks Code: -------------------- Sub Create_Factbase() Dim FileName As String Application.ScreenUpdating = False FileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) ActiveSheet.Cells.Copy Workbooks.Add Selection.PasteSpecial Paste:=xlValues Selection.PasteSpecial Paste:=xlFormats ActiveWorkbook.SaveAs FileName:=FileName + "_" + Format(Date, "dd-mm-yy") + _ "_" + Format(Time, "hh-mm-ss") ActiveSheet.Range("a1").Select Application.ScreenUpdating = True End Sub -------------------- -- soteman2005 ------------------------------------------------------------------------ soteman2005's Profile: http://www.excelforum.com/member.php...o&userid=29078 View this thread: http://www.excelforum.com/showthread...hreadid=493040 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copying named lists used in drop downs from one workbook to anothe | Excel Worksheet Functions | |||
named ranges and copying sheets to another workbook | Excel Programming | |||
Copying Sheets to New Workbook | Excel Programming | |||
Copying Sheets to New Workbook | Excel Programming | |||
copying named cells into new workbook | Excel Programming |