Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Copy two sheets into new files and save to multiple locations

Using Excel 2007 and Win XP;

I run a VBA program that sets up several sheets. Now I want to code a
distribution program that copies two of the sheets, one called "Find" and
another called "REQ" from the "program file" into a new file, then copy that
file out to three different network locations for users to view/use.

Any assistance/shortcuts you could offer in the code to do this would be
most appreciated.

Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Copy two sheets into new files and save to multiple locations

Something like the following should help (you will need to set the network
locations):

Sub DistributeSheets()

Dim wkbNew As Workbook
Dim strNetworkLocation1 As String
Dim strNetworkLocation2 As String
Dim strNetworkLocation3 As String

'Set location
strNetworkLocation1 = "D:\1\test.xls"
strNetworkLocation2 = "D:\2\test.xls"
strNetworkLocation3 = "D:\3\test.xls"

'Create new workbook and copy sheets
Set wkbNew = Workbooks.Add
ThisWorkbook.Sheets("Find").Copy Befo=wkbNew.Sheets(1)
ThisWorkbook.Sheets("REQ").Copy Befo=wkbNew.Sheets(1)

'Delete unwanted sheets
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Sheet1").Delete
Sheets("Sheet2").Delete
Sheets("Sheet3").Delete
Application.DisplayAlerts = True
On Error GoTo 0

'Save in location 1
wkbNew.SaveAs Filename:=strNetworkLocation1
wkbNew.Close
Set wkbNew = Nothing

'Copy file to other locations
FileCopy strNetworkLocation1, strNetworkLocation2
FileCopy strNetworkLocation1, strNetworkLocation3

End Sub

Please rate this post if it ansers your question.

Thanks,

Chris
www.ProfessionalExcel.com



"XP" wrote:

Using Excel 2007 and Win XP;

I run a VBA program that sets up several sheets. Now I want to code a
distribution program that copies two of the sheets, one called "Find" and
another called "REQ" from the "program file" into a new file, then copy that
file out to three different network locations for users to view/use.

Any assistance/shortcuts you could offer in the code to do this would be
most appreciated.

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Copy two sheets into new files and save to multiple locations


I'll tweak and give it a go; thanks!

"ProfessionalExcel.com" wrote:

Something like the following should help (you will need to set the network
locations):

Sub DistributeSheets()

Dim wkbNew As Workbook
Dim strNetworkLocation1 As String
Dim strNetworkLocation2 As String
Dim strNetworkLocation3 As String

'Set location
strNetworkLocation1 = "D:\1\test.xls"
strNetworkLocation2 = "D:\2\test.xls"
strNetworkLocation3 = "D:\3\test.xls"

'Create new workbook and copy sheets
Set wkbNew = Workbooks.Add
ThisWorkbook.Sheets("Find").Copy Befo=wkbNew.Sheets(1)
ThisWorkbook.Sheets("REQ").Copy Befo=wkbNew.Sheets(1)

'Delete unwanted sheets
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Sheet1").Delete
Sheets("Sheet2").Delete
Sheets("Sheet3").Delete
Application.DisplayAlerts = True
On Error GoTo 0

'Save in location 1
wkbNew.SaveAs Filename:=strNetworkLocation1
wkbNew.Close
Set wkbNew = Nothing

'Copy file to other locations
FileCopy strNetworkLocation1, strNetworkLocation2
FileCopy strNetworkLocation1, strNetworkLocation3

End Sub

Please rate this post if it ansers your question.

Thanks,

Chris
www.ProfessionalExcel.com



"XP" wrote:

Using Excel 2007 and Win XP;

I run a VBA program that sets up several sheets. Now I want to code a
distribution program that copies two of the sheets, one called "Find" and
another called "REQ" from the "program file" into a new file, then copy that
file out to three different network locations for users to view/use.

Any assistance/shortcuts you could offer in the code to do this would be
most appreciated.

Thanks in advance.

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
Save document to multiple locations Bob[_13_] New Users to Excel 1 January 19th 08 08:29 PM
save to multiple locations simultaneously MOSwannabe Excel Discussion (Misc queries) 1 October 29th 07 07:00 PM
using macros to save files in different locations Adam Excel Programming 1 July 28th 06 12:07 PM
can you automatically save files to two different locations? thrasher Excel Discussion (Misc queries) 1 June 26th 06 04:24 PM
Copy text files into multiple sheets of 1 workbook Steve[_56_] Excel Programming 0 January 14th 04 08:30 PM


All times are GMT +1. The time now is 10:06 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"