View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Automate Combine 2 Spreadsheets into two worksheets

It is pretty simple to combine multiple workbooks into a single workbook, but
I need more info

1) Where do you want the macro to run? In one of the workbooks or from a
completely seperate workbook?
2) What directory are the workbooks located?
3) What are the workbook names?
4) What are the worksheet names?

Below is a general; purpose macro that will import all book and sheets into
the workbook where the macro is run

Sub combinebooks()

Const folder = "c:\temp\test"

First = True
Do
If First = True Then
Filename = Dir(folder & "\*.xls")
First = False
Else
Filename = Dir()
End If
If Filename < "" Then
Workbooks.Open folder & "\" & Filename
Set oldbook = ActiveWorkbook
For Each sh In ActiveWorkbook.Sheets
With ThisWorkbook
sh.Copy after:=.Sheets(.Sheets.Count)
End With
Next sh
oldbook.Close
End If
Loop While Filename < ""
End Sub


"Uni" wrote:

Hi - Is there any way to automate using a macro the procedure to combine two
separate workbooks into one workbook where the separate workbooks are now on
separate worksheets? I know how to manually do this but need to automate
this for our operators who will be running this process on a weekly bases.
I'm capturing conditional data using MONARCH, exporting it out to a flat
file, importing flat file into an ACCESS program slices & dices the
information according to the requirements then exports it out into two
separate workbooks. Since I'm trying to avoid these operators from having to
open any files to manually manipulate the data (too time consuming - it
produces over 20 files) I'm looking for other alteratives.
I greatly appreciate any suggests.
Thanks in advance
Uni