View Single Post
  #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