Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Mass add of a sheet to multiple workbooks

Is it possible to add a sheet from one workbook or file to a bunch of
different work books at the same time or do I have have to copey it to them
all independently?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Mass add of a sheet to multiple workbooks

How about a macro?

Are they workbooks all in the same folder (if not put them in the same folder).
Keep the workbook with the macro and worksheet to copy in a separate folder.

Option Explicit
Sub testme01()

Dim myNames() As String
Dim fCtr As Long
Dim myFile As String
Dim myPath As String
Dim WksToCopy As Worksheet
Dim TempWkbk As Workbook

Application.ScreenUpdating = False

Set WksToCopy = ThisWorkbook.Worksheets("sheet1")

'change the folder here
myPath = "C:\my documents\excel\test"
If myPath = "" Then Exit Sub
If Right(myPath, 1) < "\" Then
myPath = myPath & "\"
End If

myFile = ""
On Error Resume Next
myFile = Dir(myPath & "*.xls")
On Error GoTo 0
If myFile = "" Then
MsgBox "no files found"
Exit Sub
End If

'get the list of files
fCtr = 0
Do While myFile < ""
fCtr = fCtr + 1
ReDim Preserve myNames(1 To fCtr)
myNames(fCtr) = myFile
myFile = Dir()
Loop

If fCtr 0 Then
For fCtr = LBound(myNames) To UBound(myNames)
Application.StatusBar _
= "Processing: " & myNames(fCtr) & " at: " & Now

Set TempWkbk = Workbooks.Open(Filename:=myPath & myNames(fCtr))

With TempWkbk
WksToCopy.Copy _
after:=.Sheets(.Sheets.Count)
End With

TempWkbk.Close savechanges:=True
Next fCtr
End If

With Application
.ScreenUpdating = True
.StatusBar = False
End With

End Sub


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

ddpderek wrote:

Is it possible to add a sheet from one workbook or file to a bunch of
different work books at the same time or do I have have to copey it to them
all independently?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Mass add of a sheet to multiple workbooks

A very simple macro can open each workbook sequentially, add in the sheet,
close the workbook and move on to the next workbook. This example has
"special" worksheet in "master.xls". The code opens Book1.xls, updates it
and then moves on to Book2.xls:

Sub Macro4()
fls = Array("Book1", "Book2")
For i = 0 To 1
Workbooks.Open Filename:="C:\" & fls(i) & ".xls"
Windows("master.xls").Activate
Sheets("special").Copy Befo=Workbooks(fls(i) & ".xls").Sheets(1)
Windows(fls(i) & ".xls").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close
Next
End Sub

--
Gary''s Student - gsnu200726


"ddpderek" wrote:

Is it possible to add a sheet from one workbook or file to a bunch of
different work books at the same time or do I have have to copey it to them
all independently?

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
inserting a sheet into multiple workbooks spence Excel Discussion (Misc queries) 2 December 19th 05 08:17 PM
Multiple Sheet workbooks [email protected] Excel Worksheet Functions 3 March 26th 05 12:57 AM
Mass Change Across Many WorkBOOKS SCSC Excel Discussion (Misc queries) 2 March 8th 05 11:43 PM
adding certain cells in multiple worksheets in multiple workbooks Stephen via OfficeKB.com Excel Worksheet Functions 1 February 4th 05 08:31 PM
Sheet protection in mass?! Kane New Users to Excel 1 January 12th 05 07:24 AM


All times are GMT +1. The time now is 04:44 AM.

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"