Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to merge 1500 files into 1!!!

I currently have 1500 different Excel files from a survey. The top ro
contains the question and the 2nd row contains the answers. What
would like to do if find a way to take the information in the 2nd ro
of each file and dump it into one spreadsheet.

I can write a macro to copy paste the information, however, the file
that I am copying the information from are obviously named differentl
and I am not sure how to tell Excel to paste in the next available ro
only a particular cell.

Is there a way that I could automate this entire process instead o
opening up each file and copy paste?

Any help in the right direction is greatly appreciated!
Thanks in advance

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need to merge 1500 files into 1!!!

Try something like the following code:

Sub MergeFiles()
Dim FName As String
Dim WB As Workbook
Dim Dest As Range
Const FOLDERNAME = "C:\Temp" '<<< CHANGE
ChDrive FOLDERNAME
ChDir FOLDERNAME

Set Dest = Range("A1")
FName = Dir("*.xls")

Do Until FName = ""
Set WB = Workbooks.Open(FName)
WB.Worksheets(1).Rows(2).Copy Destination:=Dest
WB.Close savechanges:=False
Set Dest = Dest(2, 1)
FName = Dir()
Loop
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"rglasunow " wrote in
message ...
I currently have 1500 different Excel files from a survey. The

top row
contains the question and the 2nd row contains the answers.

What I
would like to do if find a way to take the information in the

2nd row
of each file and dump it into one spreadsheet.

I can write a macro to copy paste the information, however, the

files
that I am copying the information from are obviously named

differently
and I am not sure how to tell Excel to paste in the next

available row
only a particular cell.

Is there a way that I could automate this entire process

instead of
opening up each file and copy paste?

Any help in the right direction is greatly appreciated!
Thanks in advance!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Need to merge 1500 files into 1!!!

Hi

Try the example on my Tips page
http://www.rondebruin.nl/tips.htm

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"rglasunow " wrote in message ...
I currently have 1500 different Excel files from a survey. The top row
contains the question and the 2nd row contains the answers. What I
would like to do if find a way to take the information in the 2nd row
of each file and dump it into one spreadsheet.

I can write a macro to copy paste the information, however, the files
that I am copying the information from are obviously named differently
and I am not sure how to tell Excel to paste in the next available row
only a particular cell.

Is there a way that I could automate this entire process instead of
opening up each file and copy paste?

Any help in the right direction is greatly appreciated!
Thanks in advance!


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to merge 1500 files into 1!!!

Thank you so much for your help. This worked great. You just saved me
from Ctrl+C & Ctrl+V 1500 times!!!

I just have one more question.

Under this command - Do Until FName = ""

Is this going through the folder I selected in alphabetical order?
Thank you,
Ryan


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Need to merge 1500 files into 1!!!

Is this going through the folder I selected in alphabetical order?
Yes

You can use this for example to fill in the filename also
<basebook.Worksheets(1).Cells(rnum, 4) = mybook.Name
4 is the column, if you copy a range more then 3 columns width then change this

Set mybook = Workbooks.Open(FNames)
Set sourceRange = mybook.Worksheets(1).Range("a1:c3")
a = sourceRange.Rows.Count
Set destrange = basebook.Worksheets(1).Cells(rnum, 1)
sourceRange.Copy destrange
basebook.Worksheets(1).Cells(rnum, 4) = mybook.Name


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"rglasunow " wrote in message ...
Thank you so much for your help. This worked great. You just saved me
from Ctrl+C & Ctrl+V 1500 times!!!

I just have one more question.

Under this command - Do Until FName = ""

Is this going through the folder I selected in alphabetical order?
Thank you,
Ryan


---
Message posted from http://www.ExcelForum.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
merge two excel files like in word mail merge azmerritt Excel Discussion (Misc queries) 1 December 11th 16 09:23 PM
Time format 1500 become 15:00 tran1728 Excel Discussion (Misc queries) 4 May 7th 10 12:33 AM
merge 2 files reza Excel Discussion (Misc queries) 3 January 26th 10 05:53 PM
I wana prepare a pay roll of employee of 1500 [email protected] Excel Discussion (Misc queries) 2 July 21st 07 01:20 PM
'Average' Function on 1500 lines Logan New Users to Excel 2 May 25th 05 11:40 PM


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"