Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying Several Sheets To a New Uniquely Named Workbook


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying Several Sheets To a New Uniquely Named Workbook

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying named lists used in drop downs from one workbook to anothe Kevin L. Excel Worksheet Functions 0 November 9th 06 10:02 PM
named ranges and copying sheets to another workbook helpwithXL Excel Programming 1 May 17th 05 04:57 PM
Copying Sheets to New Workbook Ray Batig Excel Programming 2 April 3rd 05 12:23 AM
Copying Sheets to New Workbook Tom Ogilvy Excel Programming 0 April 2nd 05 05:57 PM
copying named cells into new workbook GJR3599 Excel Programming 1 April 2nd 05 05:25 PM


All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"