PC Review


Reply
Thread Tools Rate Thread

Copy two sheets into new files and save to multiple locations

 
 
XP
Guest
Posts: n/a
 
      26th Nov 2008
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 With Quote
 
 
 
 
ProfessionalExcel.com
Guest
Posts: n/a
 
      26th Nov 2008
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 Before:=wkbNew.Sheets(1)
ThisWorkbook.Sheets("REQ").Copy Before:=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 With Quote
 
XP
Guest
Posts: n/a
 
      26th Nov 2008

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 Before:=wkbNew.Sheets(1)
> ThisWorkbook.Sheets("REQ").Copy Before:=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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save document to multiple locations Bob Microsoft Excel New Users 1 19th Jan 2008 08:29 PM
save to multiple locations simultaneously =?Utf-8?B?TU9Td2FubmFiZQ==?= Microsoft Excel Misc 1 29th Oct 2007 07:00 PM
Can I save in multiple locations (folders) simultaneously? =?Utf-8?B?a3Jvd2xhbg==?= Microsoft Powerpoint 1 19th Jan 2006 03:55 PM
Copy text files into multiple sheets of 1 workbook Steve Microsoft Excel Programming 0 14th Jan 2004 08:30 PM
Multiple file save locations Mark M.. Windows XP Networking 0 4th Oct 2003 06:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:59 PM.