Solved

Combining excel files and extracting data using macros

Posted on 2007-11-27
4
3,423 Views
Last Modified: 2013-11-26
How do I combine all Excel files in a folder into a single Excel sheet?
0
Comment
Question by:alfran1026
4 Comments
 
LVL 11

Accepted Solution

by:
bsharath earned 125 total points
ID: 20363328
I know a way to combine txt or cvv files to excel files but not excel to 1 single excel.I dont think it is possible also.
If you want i can share any of them.
0
 
LVL 6

Assisted Solution

by:CRJ2000
CRJ2000 earned 125 total points
ID: 20510827
This could be done via VBA or VBScript. To answer your question we would need to know more details about what you actually want to do...

Do you truly want all of the information placed into a single worksheet (not workbook)?
How many Excel documents are there, and what is the average number of rows?
Are there multiple sheets in each workbook? Do you want the solution to import all of the sheets?

See the code snippet for a general idea of how this could be done (untested)...
Dim wbDest as workbook

Dim wsDest as worksheet

Dim wbSource as workbook

Dim wsSource as worksheet

Dim FSO as object

Dim Fol as object

Dim fi as object
 

'Get a reference to the destination workbook.

set wbDest = ThisWorkbook

set wsDest = wbDest.worksheets(1)
 

'Create a new FileSystemObject. We'll use this to loop through

'the files.

set fso = createobject("scripting.filesystemobject")

set fol = fso.getfolder("c:\Source Documents")
 

'Loop through the files.

for each fi in fol.files
 

  'Open the workbook and get the first worksheet.

  set wbSource = excel.workbooks.open(fi.path)

  set wsSource = wbsource.worksheets(1)
 

  'Here you would add code to copy the data from one workbook to the other. There are many options on how to do this. The method depends on the answers to the questions above.
 

  'Close the workbook.

  wbSource.close
 

next

Open in new window

0
 
LVL 1

Expert Comment

by:Computer101
ID: 21447731
Forced accept.

Computer101
EE Admin
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now