Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Consolidating Several Excel Files

Hi...

I am about to send out a template (Say file A) to many users, who will
fill details in the template and then send back to me.

I have a summary tab (Say Tab bb) in the template going out that
summarises all data contained within the template.

Once I recieve all the File A's back (approx 100) I need to consolidate
the tabs (ie Tab bb) , ie compare the submissions side by side in one
workbook
Is there any easier way than copying and pasting the sheet 100 times)
Any consolidation type process that can automatically be run by a Macro?
Anything I need to add to my File A (or Tab bb) sheet before sending
out...?

Thanks and Regards

D


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Consolidating Several Excel Files

assume you put all your files in a single directory

Dim i as Long, sName as String, sh as Worksheet
Dim dest as Range, bk as Workbook
i = 1
sName = dir("C:\MyResultsFiles\*.xls")
do while sName < ""
set bk = workbooks.Open("C:\MyResultsFiles\" & sName)
set sh = bk.worksheets("Tab bb")
set dest = workbooks("Output.xls).Worksheets(1).cells(1,i)
i = i + 1
sh.Columns(1).copy
dest.PasteSpecial xlValues
dest.PasteSpecial xlFormats
' write name of the workbook in row 1
dest.Value = sName
' close the workbook
bk.close SaveChanges:=False
sName = dir()
Loop

Of course if all the workbooks have the exact same name, this wouldn't work.

--
Regards,
Tom Ogilvy


"Darin Kramer" wrote in message
...
Hi...

I am about to send out a template (Say file A) to many users, who will
fill details in the template and then send back to me.

I have a summary tab (Say Tab bb) in the template going out that
summarises all data contained within the template.

Once I recieve all the File A's back (approx 100) I need to consolidate
the tabs (ie Tab bb) , ie compare the submissions side by side in one
workbook
Is there any easier way than copying and pasting the sheet 100 times)
Any consolidation type process that can automatically be run by a Macro?
Anything I need to add to my File A (or Tab bb) sheet before sending
out...?

Thanks and Regards

D


*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Consolidating Several Excel Files

Thanks Tom.

Where do I put that VBA. Into a module of a blank consolidated book? How
do I "run" it??

Appreciate your help....

D



*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Consolidating Several Excel Files

I just created a normal sub, and it runs, but I get an error (Script out
of Range) on the line

"Set dest = Workbooks("Consol2.xls").Worksheets(1).Cells(1, i)"

Does the sheet conso2.xls have to be in the same sub directory, or does
there need to be a sheet at all (ie is it created or must it be pre
created? "


Thanks

D


*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Consolidating Several Excel Files


Tom,

I also need to copy columns 1 to 3 instead of just one.

Whats the VB for that sh.columns(1,3) copy?

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Consolidating Several Excel Files

As written, you could put it in any workbook except one of the workbooks to
be process - however, I have modified it to be placed in a blank
consolidation workbook.

Sub DarinsConsolidator()
Dim i as Long, sName as String, sh as Worksheet
Dim dest as Range, bk as Workbook
i = 1
sName = dir("C:\MyResultsFiles\*.xls")
do while sName < ""
set bk = workbooks.Open("C:\MyResultsFiles\" & sName)
set sh = bk.worksheets("Tab bb")
set dest = ThisWorkbook.Worksheets(1).cells(1,i)
i = i + 1
sh.Columns(1).copy
dest.PasteSpecial xlValues
dest.PasteSpecial xlFormats
' write name of the workbook in row 1
dest.Value = sName
' close the workbook
bk.close SaveChanges:=False
sName = dir()
Loop
End Sub

then put the above in a normal Module (insert module) in that workbook.
Then go to Tools=Macro=Macros, select DarinsConsolidator and hit run.

--
Regards,
Tom Ogilvy


"Darin Kramer" wrote in message
...
Thanks Tom.

Where do I put that VBA. Into a module of a blank consolidated book? How
do I "run" it??

Appreciate your help....

D



*** Sent via Developersdex http://www.developersdex.com ***



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Consolidating Several Excel Files

As shown, Consol2.xls is the name of the workbook, not the worksheet and the
workbook must be open. the Worksheets(1) refers to the sheet - the first
sheet in the tab order in Consol2.xls regardless of name.

--
Regards,
Tom Ogilvy

"Darin Kramer" wrote in message
...
I just created a normal sub, and it runs, but I get an error (Script out
of Range) on the line

"Set dest = Workbooks("Consol2.xls").Worksheets(1).Cells(1, i)"

Does the sheet conso2.xls have to be in the same sub directory, or does
there need to be a sheet at all (ie is it created or must it be pre
created? "


Thanks

D


*** Sent via Developersdex http://www.developersdex.com ***



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Consolidating Several Excel Files

Sub DarinsConsolidator()
Dim i as Long, sName as String, sh as Worksheet
Dim dest as Range, bk as Workbook
i = 1
sName = dir("C:\MyResultsFiles\*.xls")
do while sName < ""
set bk = workbooks.Open("C:\MyResultsFiles\" & sName)
set sh = bk.worksheets("Tab bb")
set dest = ThisWorkbook.Worksheets(1).cells(1,i)
i = i + 3
sh.Columns(1).Resize(,3).copy
dest.PasteSpecial xlValues
dest.PasteSpecial xlFormats
' write name of the workbook in row 1
dest.Value = sName
' close the workbook
bk.close SaveChanges:=False
sName = dir()
Loop
End Sub

Just note that there are only 3 hundred columns in a worksheet, so 3 x 100 =
300 and you would run out of space.

--
Regards,
Tom Ogilvy



"Darin Kramer" wrote in message
...

Tom,

I also need to copy columns 1 to 3 instead of just one.

Whats the VB for that sh.columns(1,3) copy?

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***



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
Need advice : consolidating data from multiple CSV files in Excel - External data handling Matthieu Gaillet Excel Programming 0 December 1st 05 09:02 AM
excel consolidating Eagle784 Excel Worksheet Functions 1 June 13th 05 11:44 PM
Consolidating tab-delimited text files John V[_3_] Excel Programming 0 August 6th 04 12:45 AM
Consolidating multiple files into 1 target Mark[_26_] Excel Programming 1 September 27th 03 04:19 PM
Consolidating multiple files using a row column range Jim[_16_] Excel Programming 2 July 10th 03 09:26 PM


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