PC Review


Reply
Thread Tools Rate Thread

Combine Workbooks with Same Prefix into One New Workbook

 
 
=?Utf-8?B?ZXQxMHls?=
Guest
Posts: n/a
 
      9th Nov 2006
I have a folder with several hundred workbooks. Some workbooks have the same
prefix. I'd like to combine all the worksheets from workbooks with the same
prefix into one workbook, and save this combined workbook as a new workbook.
I tried using this but it doesn't seem to work. Also, I had programmed a
user form to get the value of the prefix, but it doesn't seem to be passing
the value to the Module? Any help would be appreciated. Thanks!

Sub CombineFiles()
Dim prefix as String

Do Until FileName = ""

If FileName = Dir(Path & "\" & prefix & "*.xls", vbNormal) Then

Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
For Each WS In Wkb.Worksheets
WS.Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
Next WS
Wkb.Close False
FileName = Dir()

End If
Loop
End Sub
 
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
Combine workstheets of multipel workbooks into one workbook using a macro Sam Commar Microsoft Excel Programming 5 2nd Apr 2009 03:06 PM
Combine multiple workbooks into one workbook YM TEO Microsoft Excel Misc 1 25th Mar 2009 10:09 AM
Compare two Workbooks and combine data into one workbook SBonner Microsoft Excel Programming 0 13th Jul 2006 01:19 AM
Combine workbooks into one master workbook. EKB Microsoft Excel Programming 2 6th May 2006 11:08 AM
Combine multiple workbooks into one workbook =?Utf-8?B?Um9va2llX1VzZXI=?= Microsoft Excel Misc 0 13th Jan 2006 06:56 PM


Features
 

Advertising
 

Newsgroups
 


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