Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy a File 'n' Times, New Filenames are "File_n.xls"

I have a "master" spreadsheet and a "template" spreadsheet. The master
has various things on it and will be used to aggregate data from
multiple workbooks. One sheet in the master has a list of departments
(say deptA, deptB, deptC...). I have a button on the sheet that I want
to use to generate a copy of the template for each dept in the list
(code below). All files reside in the same folder. I currently have
pieced together working code for various pieces of what I want but
cannot get it to work all together. I am very new at VBA. Your help is
much appreciated!!!

In the code "test.xls" is the template file.

-------
Option Explicit
Private Sub CommandButton1_Click()
Dim myCell As Range
Dim sourceFile, myName
sourceFile = "test.xls"


With Worksheets("Sheet1")
For Each myCell In .Range(("A1"), _
.Cells(.Rows.Count, 1).End(xlUp)).Cells

FileCopy sourceFile, myCell.Value & ".xls"

Next myCell
End With
End Sub

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
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
Excel adds a "1" to filenames opened from desktop shortcut skibeaux Excel Discussion (Misc queries) 4 June 20th 07 09:05 PM
Lost "File Menu" - now it's "Edit / View / Insert.." but no "F daves Excel Discussion (Misc queries) 3 April 24th 07 04:52 AM
Open multiple "unknown" filenames within a macro (array setup) need_some_help Excel Programming 8 July 23rd 05 09:00 AM
Controlling image filenames during "Save As Webpage" ... Greg_Del_Pilar Excel Programming 2 October 8th 03 07:56 AM


All times are GMT +1. The time now is 11:09 PM.

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

About Us

"It's about Microsoft Excel"