Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Newsgal
 
Posts: n/a
Default How do you merge separate Excel workbooks into one workbook?

We have over 100 Excel workbooks (1 active worksheet in each) that we need to
merge into just one worksheet in one workbook. All worksheets have the same
column headers, but some have more data than others. Is there a quick way to
do this?
--
News Gal
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gazeta
 
Posts: n/a
Default How do you merge separate Excel workbooks into one workbook?


Użytkownik "Newsgal" napisał w
wiadomości ...
We have over 100 Excel workbooks (1 active worksheet in each) that we need

to
merge into just one worksheet in one workbook. All worksheets have the

same
column headers, but some have more data than others. Is there a quick way

to
do this?
--
News Gal


create file with your headers then ust this sub (it works for 2
columns-change it to your area and assumes that if you open your files it
will be ready to copy data i mean activesheet will be the one with data):
Sub merge()
Set active = ActiveSheet

With Application.FileSearch
.NewSearch
.LookIn = "your folder path"
If .LookIn = "" Then Exit Sub
.SearchSubFolders = True
.Filename = "*.xls"
.Execute

Rownumber = 2

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For i = 1 To .FoundFiles.Count
'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
Set myrange = Range("a2:b" & Range("a1").CurrentRegion.Rows.Count)
dane.Copy active.Cells(Rownumber, 1)
wiersz = Rownumber + myrange.Rows.Count
ActiveWorkbook.Close

Next
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

mcg



  #3   Report Post  
Posted to microsoft.public.excel.misc
Newsgal
 
Posts: n/a
Default How do you merge separate Excel workbooks into one workbook?

Hi, Gazeta,
As a novice to VB, I'm wondering about two parts of your module below:
1) the word "dane" in front of Copy Active.Cells (Rownumber,1)
2) the word "wiersz" = Rownumber + myrange.Rows.count.

Should I be overriding these to something specific to my spreadsheet? At
this point the Macro runs and nothing happens. Here's what I set up:

Sub merge()
Set Active = ActiveSheet

With Application.FileSearch
..NewSearch
..LookIn = "C:\Documents and Settings\advert\Desktop\Active Accounts"
If .LookIn = "" Then Exit Sub
..SearchSubFolders = True
..Filename = "*.xls"
..Execute

Rownumber = 2

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For i = 1 To .FoundFiles.Count
'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
Set myrange = Range("a2:m" & Range("a1").CurrentRegion.Rows.Count)
dane.Copy Active.Cells(Rownumber, 1)
wiersz = Rownumber + myrange.Rows.Count
ActiveWorkbook.Close

Next
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

thanks,
News Gal


"Gazeta" wrote:


UÂżytkownik "Newsgal" napisaÂł w
wiadomoÂści ...
We have over 100 Excel workbooks (1 active worksheet in each) that we need

to
merge into just one worksheet in one workbook. All worksheets have the

same
column headers, but some have more data than others. Is there a quick way

to
do this?
--
News Gal


create file with your headers then ust this sub (it works for 2
columns-change it to your area and assumes that if you open your files it
will be ready to copy data i mean activesheet will be the one with data):
Sub merge()
Set active = ActiveSheet

With Application.FileSearch
.NewSearch
.LookIn = "your folder path"
If .LookIn = "" Then Exit Sub
.SearchSubFolders = True
.Filename = "*.xls"
.Execute

Rownumber = 2

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For i = 1 To .FoundFiles.Count
'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
Set myrange = Range("a2:b" & Range("a1").CurrentRegion.Rows.Count)
dane.Copy active.Cells(Rownumber, 1)
wiersz = Rownumber + myrange.Rows.Count
ActiveWorkbook.Close

Next
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub






  #4   Report Post  
Posted to microsoft.public.excel.misc
Gazeta
 
Posts: n/a
Default How do you merge separate Excel workbooks into one workbook?


Użytkownik "Newsgal" napisał w
wiadomości ...
Hi, Gazeta,
As a novice to VB, I'm wondering about two parts of your module below:
1) the word "dane" in front of Copy Active.Cells (Rownumber,1)
2) the word "wiersz" = Rownumber + myrange.Rows.count.

Should I be overriding these to something specific to my spreadsheet? At
this point the Macro runs and nothing happens. Here's what I set up:

Sub merge()
Set Active = ActiveSheet

With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\advert\Desktop\Active Accounts"
If .LookIn = "" Then Exit Sub
.SearchSubFolders = True
.Filename = "*.xls"
.Execute

Rownumber = 2

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For i = 1 To .FoundFiles.Count
'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
Set myrange = Range("a2:m" & Range("a1").CurrentRegion.Rows.Count)
dane.Copy Active.Cells(Rownumber, 1)
wiersz = Rownumber + myrange.Rows.Count
ActiveWorkbook.Close

Next
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

thanks,
News Gal


"Gazeta" wrote:


U?ytkownik "Newsgal" napisa3 w
wiadomo?ci ...
We have over 100 Excel workbooks (1 active worksheet in each) that we

need
to
merge into just one worksheet in one workbook. All worksheets have the

same
column headers, but some have more data than others. Is there a quick

way
to
do this?
--
News Gal


create file with your headers then ust this sub (it works for 2
columns-change it to your area and assumes that if you open your files

it
will be ready to copy data i mean activesheet will be the one with

data):
Sub merge()
Set active = ActiveSheet

With Application.FileSearch
.NewSearch
.LookIn = "your folder path"
If .LookIn = "" Then Exit Sub
.SearchSubFolders = True
.Filename = "*.xls"
.Execute

Rownumber = 2

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For i = 1 To .FoundFiles.Count
'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
Set myrange = Range("a2:b" & Range("a1").CurrentRegion.Rows.Count)
dane.Copy active.Cells(Rownumber, 1)
wiersz = Rownumber + myrange.Rows.Count
ActiveWorkbook.Close

Next
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub



sorry i copied this sub from my language
change wiersz to rownumber and dane to myrange
mcg


  #5   Report Post  
Posted to microsoft.public.excel.misc
JB
 
Posts: n/a
Default How do you merge separate Excel workbooks into one workbook?

Consolide WorkBooks of one directory

http://cjoint.com/?ffwaa2fy1C

Sub syntčseClasseursBD()
[A2].CurrentRegion.Offset(1, 0).Resize().Clear
[A2].Select
fenetre = ActiveWorkbook.Name
ChDir ActiveWorkbook.Path ' Directory of actuel workbook
nf = Dir("*.xls") ' First file in the directory
Do While nf < ""
Workbooks.Open Filename:=nf
Windows(fenetre).Activate
Workbooks(nf).ActiveSheet.[A1].CurrentRegion.Offset(1,
0).Resize().Copy ActiveCell
Workbooks(nf).Close False
[A1].End(xlDown).Offset(1, 0).Select
nf = Dir ' Next file
If nf = ActiveWorkbook.Name Then nf = Dir
Loop
End Sub

Cordialy JB



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
How can I merge and link workbooks into one summary workbook? Sylvia Excel Worksheet Functions 3 July 31st 08 09:55 PM
Merge worksheets from separate files into one workbook. dagriffin Excel Discussion (Misc queries) 6 April 20th 06 06:56 PM
How can I get existing Excel workbooks to open in separate windows Christy99 Excel Worksheet Functions 1 March 22nd 05 12:26 AM
Automate Excel to powerpoint - Graphs along with Datasheet (not workbook) Hari Prasadh Charts and Charting in Excel 4 February 17th 05 02:44 PM
Linking Workbooks Dede McEachern Excel Worksheet Functions 0 January 21st 05 08:27 PM


All times are GMT +1. The time now is 04:39 PM.

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"