LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default How to copy a workbook

Hi Les, Since you have the emplyee names in an array, you can use the array
name as the variable to name the workbook.

myNames = Array(Name1, Name2, Name3....Namen)
myPath = ThisWorkbook.Path '<<<assumes same folder as master
For i = LBound(myNames) To UBound(myNames)
ThisWorkbook.SaveAs FileName:=myPath & "\" & myNames(i) & ".xls"
Next

The SaveAS method is creating a copy of the master workbook and naming it
with a name from the array of employee names. This assumes the array of
names is for new employees only. If not, then you would have to create a
separate variable for the new employee name and use that where the
myNames(i) array variable is used above.




"WLMPilot" wrote in message
...
Thanks. I apologize for not making this clearer. I will have a MASTER
workbook that is used by the boss. Inside the Master workbook will be a
commandbutton to execute a macro that will copy the TEMPLATE workbook and
rename it to match the employee(s) name.

There will be a list of all employees in the Master workbook that I will
read into an array to initially set everything up to match the current
employees. After that, I will have it worked out to copy the TEMPLATE for
each new employee.

Therefore, the code is actually in the MASTER workbook. I wanted to know
what the actual code that will copy the TEMPLATE and rename it (using a
variable that holds the employee's name) will be. I believe I will be
able
to add that addition code to read the names.

Thanks,
Les

"Mike H" wrote:

Hi,

This would go in your 'template' workbook.

This string
S = "aaa,bbb,ccc"

should be changed to your list of employees


Sub Sonic()
Dim V As Variant
Dim S As String

S = "aaa,bbb,ccc"
V = Split(S, ",")
For x = 0 To UBound(V)
ThisWorkbook.SaveAs Filename:=V(x)
Next x
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"WLMPilot" wrote:

I need to know how to copy a workbook in a macro (Excel 2002)
The filename of the workbook to be copied is "Template" (w/o quotes)
The new workbook will have the name of an employee, ie several
workbooks,
each having the name of an employee.

Variable: EMP = "John Doe"
Code needed to copy workbook TEMPLATE and rename to variable EMP.

Thanks,
Les



 
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
Copy Autofilter Source Workbook A result in Destination Workbook BSheet1 u473 Excel Programming 1 September 9th 08 05:14 PM
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Copy data from Workbook Alpha & reorganize it in Workbook Bravo u473 Excel Programming 1 October 31st 07 02:37 AM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM


All times are GMT +1. The time now is 09:55 AM.

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"