Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default I have many excel files, would like to aggregate into one

I have by bad system design in earlier stage received about 500 pcs of small
individual Excel files of exakt the same design but with data of different
items. Each file normally holds between 20 - 30 records (rows).
I now have a need to aggregate all these files into one single Excel or
Access file and would like to avoid all the work with to open each invidual
file and copy and paste.
Does any kind person know any practical method available?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 145
Default I have many excel files, would like to aggregate into one

Loop,
open each workbook,
copy the rows of data to bottom of destination workbook,
close current workbook,
next file
save current workbook

"Gunnar" wrote in message
...
I have by bad system design in earlier stage received about 500 pcs of

small
individual Excel files of exakt the same design but with data of different
items. Each file normally holds between 20 - 30 records (rows).
I now have a need to aggregate all these files into one single Excel or
Access file and would like to avoid all the work with to open each

invidual
file and copy and paste.
Does any kind person know any practical method available?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default I have many excel files, would like to aggregate into one

Assume all the files (and only the files) are in a subdirectory - C:\MyFolder
for illustration

Sub GatherInformation()
Dim sPath as String, sName as String
Dim bk as Workbook, rng as Range
Dim rng1 as Range
sPath = "C:\MyFolder\"
sName = dir(sPath & "*.xls")
do while sName < ""
set bk = workbooks.Open(sPath & sName)
set rng = Thisworkbooks.worksheets(1).Cells(rows.count,1).En d(xlup)(2)
with bk.Worksheets(1)
set rng1 = .Range(.Cells(1,1),.cells(rows.count,1).End(xlup))
end with
rng1.entirerow.copy destination:=rng
bk.close SaveChanges:=False
sName = dir()
Loop
End Sub

--
Regards,
Tom Ogilvy

--
Regards,
Tom Ogilvy]

"Gunnar" wrote:

I have by bad system design in earlier stage received about 500 pcs of small
individual Excel files of exakt the same design but with data of different
items. Each file normally holds between 20 - 30 records (rows).
I now have a need to aggregate all these files into one single Excel or
Access file and would like to avoid all the work with to open each invidual
file and copy and paste.
Does any kind person know any practical method available?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default I have many excel files, would like to aggregate into one

Thanks Tom,

Looks impressing, but I don't understand all the details. I suppose it
should be loaded as a VBA-module and executed as a macro and the only changes
I have to do is to edit line 5 (the sPath-line) pointing out the
subdirectory.

But nothing at all happens when executed. Is there any requirement that the
Excel-files shall be shared or similar?

Thank you very much for your effort.

Regards,
Gunnar

"Tom Ogilvy" wrote:

Assume all the files (and only the files) are in a subdirectory - C:\MyFolder
for illustration

Sub GatherInformation()
Dim sPath as String, sName as String
Dim bk as Workbook, rng as Range
Dim rng1 as Range
sPath = "C:\MyFolder\"
sName = dir(sPath & "*.xls")
do while sName < ""
set bk = workbooks.Open(sPath & sName)
set rng = Thisworkbooks.worksheets(1).Cells(rows.count,1).En d(xlup)(2)
with bk.Worksheets(1)
set rng1 = .Range(.Cells(1,1),.cells(rows.count,1).End(xlup))
end with
rng1.entirerow.copy destination:=rng
bk.close SaveChanges:=False
sName = dir()
Loop
End Sub

--
Regards,
Tom Ogilvy

--
Regards,
Tom Ogilvy]

"Gunnar" wrote:

I have by bad system design in earlier stage received about 500 pcs of small
individual Excel files of exakt the same design but with data of different
items. Each file normally holds between 20 - 30 records (rows).
I now have a need to aggregate all these files into one single Excel or
Access file and would like to avoid all the work with to open each invidual
file and copy and paste.
Does any kind person know any practical method available?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default I have many excel files, would like to aggregate into one

Hi again,

I now noticed the remark "Can't execute code in Break Mode".

/Gunnar

"Tom Ogilvy" wrote:

Assume all the files (and only the files) are in a subdirectory - C:\MyFolder
for illustration

Sub GatherInformation()
Dim sPath as String, sName as String
Dim bk as Workbook, rng as Range
Dim rng1 as Range
sPath = "C:\MyFolder\"
sName = dir(sPath & "*.xls")
do while sName < ""
set bk = workbooks.Open(sPath & sName)
set rng = Thisworkbooks.worksheets(1).Cells(rows.count,1).En d(xlup)(2)
with bk.Worksheets(1)
set rng1 = .Range(.Cells(1,1),.cells(rows.count,1).End(xlup))
end with
rng1.entirerow.copy destination:=rng
bk.close SaveChanges:=False
sName = dir()
Loop
End Sub

--
Regards,
Tom Ogilvy

--
Regards,
Tom Ogilvy]

"Gunnar" wrote:

I have by bad system design in earlier stage received about 500 pcs of small
individual Excel files of exakt the same design but with data of different
items. Each file normally holds between 20 - 30 records (rows).
I now have a need to aggregate all these files into one single Excel or
Access file and would like to avoid all the work with to open each invidual
file and copy and paste.
Does any kind person know any practical method available?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default I have many excel files, would like to aggregate into one

Thanks Tom

I got it working now. I had a very typical error - a missing \ at the end
of sPath.

I am most grateful - a lot of work is not necessary any longer.

Regards,
Gunnar

"Tom Ogilvy" wrote:

Assume all the files (and only the files) are in a subdirectory - C:\MyFolder
for illustration

Sub GatherInformation()
Dim sPath as String, sName as String
Dim bk as Workbook, rng as Range
Dim rng1 as Range
sPath = "C:\MyFolder\"
sName = dir(sPath & "*.xls")
do while sName < ""
set bk = workbooks.Open(sPath & sName)
set rng = Thisworkbooks.worksheets(1).Cells(rows.count,1).En d(xlup)(2)
with bk.Worksheets(1)
set rng1 = .Range(.Cells(1,1),.cells(rows.count,1).End(xlup))
end with
rng1.entirerow.copy destination:=rng
bk.close SaveChanges:=False
sName = dir()
Loop
End Sub

--
Regards,
Tom Ogilvy

--
Regards,
Tom Ogilvy]

"Gunnar" wrote:

I have by bad system design in earlier stage received about 500 pcs of small
individual Excel files of exakt the same design but with data of different
items. Each file normally holds between 20 - 30 records (rows).
I now have a need to aggregate all these files into one single Excel or
Access file and would like to avoid all the work with to open each invidual
file and copy and paste.
Does any kind person know any practical method available?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default I have many excel files, would like to aggregate into one


Your efforts are very nice. Please try to define the variabels names more
clearly and try to put more comments for easy understanding of beginners.
But code is very useful.

"Tom Ogilvy" wrote:

Assume all the files (and only the files) are in a subdirectory - C:\MyFolder
for illustration

Sub GatherInformation()
Dim sPath as String, sName as String
Dim bk as Workbook, rng as Range
Dim rng1 as Range
sPath = "C:\MyFolder\"
sName = dir(sPath & "*.xls")
do while sName < ""
set bk = workbooks.Open(sPath & sName)
set rng = Thisworkbooks.worksheets(1).Cells(rows.count,1).En d(xlup)(2)
with bk.Worksheets(1)
set rng1 = .Range(.Cells(1,1),.cells(rows.count,1).End(xlup))
end with
rng1.entirerow.copy destination:=rng
bk.close SaveChanges:=False
sName = dir()
Loop
End Sub

--
Regards,
Tom Ogilvy

--
Regards,
Tom Ogilvy]

"Gunnar" wrote:

I have by bad system design in earlier stage received about 500 pcs of small
individual Excel files of exakt the same design but with data of different
items. Each file normally holds between 20 - 30 records (rows).
I now have a need to aggregate all these files into one single Excel or
Access file and would like to avoid all the work with to open each invidual
file and copy and paste.
Does any kind person know any practical method available?

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
Aggregate tables nc Excel Discussion (Misc queries) 0 September 12th 08 03:35 PM
How to refer to external datasource in Excel domain aggregate func Jim Molter Excel Worksheet Functions 0 October 25th 07 08:05 PM
Why do OWC charts aggregate data when Excel doesn't? Floored Charts and Charting in Excel 0 December 28th 05 02:34 AM
How to get Excel to retrieve aggregate data from Access Don MacKinnon Excel Programming 1 December 1st 05 07:10 PM
How to aggregate in Excel? Frank Krogh Excel Programming 1 March 4th 04 02:31 PM


All times are GMT +1. The time now is 11:44 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"