PC Review


Reply
Thread Tools Rate Thread

combine sheets from several workbooks into one

 
 
Amy
Guest
Posts: n/a
 
      10th Nov 2009
I have a folder full of workbooks that I need to take the first sheet out of
and combine them all into one workbook. I need each of the worksheets to keep
the names they have in the original worksheet. Does anyone have an existing
macro that will do this? Thanks!
 
Reply With Quote
 
 
 
 
Matthew Herbert
Guest
Posts: n/a
 
      10th Nov 2009
Amy,

You can try something along the lines of what is below. I'm using a file
filter of *.csv, but you can change the file extension to be what you need it
to be. (Depending on how your data is setup, e.g. csv file or formatted data
with formulas, there maybe faster ways to accomplish this task).

Best,

Matthew Herbert

Sub CombineCSVFIles()
Dim varFiles As Variant
Dim lngCnt As Long
Dim Wkb As Workbook
Dim Wks As Worksheet

varFiles = Application.GetOpenFilename(FileFilter:=", *.csv",
MultiSelect:=True)

If TypeName(varFiles) = "Boolean" Then
MsgBox "No files selected."
Exit Sub
End If

Set Wkb = Workbooks.Add
For lngCnt = LBound(varFiles) To UBound(varFiles)
Set Wks = Workbooks.Open(varFiles(lngCnt)).Worksheets(1)
Wks.Copy Wkb.Worksheets(1)
Wks.Parent.Close False
Next lngCnt
End Sub
"Amy" wrote:

> I have a folder full of workbooks that I need to take the first sheet out of
> and combine them all into one workbook. I need each of the worksheets to keep
> the names they have in the original worksheet. Does anyone have an existing
> macro that will do this? Thanks!

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I merge/combine different workbooks with different sheets =?Utf-8?B?U3RldmUgRGVzY2hhcm1l?= Microsoft Excel Worksheet Functions 2 2nd Apr 2007 08:54 PM
Merge / Add / Combine Sheets from different Workbooks =?ISO-8859-1?B?QW5k7w==?= Microsoft Excel Programming 1 29th Aug 2006 05:57 PM
HELP TO COMBINE MULTIPLE SHEETS IN MULTIPLE WORKBOOKS =?Utf-8?B?RWRkeSBTdGFu?= Microsoft Excel Programming 12 13th Mar 2006 12:46 PM
Can I combine 100+ sheets from different workbooks into one worksheet? Michelle Microsoft Excel Misc 2 8th Apr 2005 09:17 PM
Combine Sheets From Different Workbooks =?Utf-8?B?VGltIEZvcnR1bmU=?= Microsoft Excel Programming 4 17th Jan 2004 11:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:30 PM.