Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
inserting a sheet into multiple workbooks | Excel Discussion (Misc queries) | |||
Multiple Sheet workbooks | Excel Worksheet Functions | |||
Mass Change Across Many WorkBOOKS | Excel Discussion (Misc queries) | |||
adding certain cells in multiple worksheets in multiple workbooks | Excel Worksheet Functions | |||
Sheet protection in mass?! | New Users to Excel |