Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Combine Workbooks with Same Prefix into One New Workbook

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.Cou nt)
Next WS
Wkb.Close False
FileName = Dir()

End If
Loop
End Sub
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
Combine multiple workbooks into one workbook YM TEO Excel Discussion (Misc queries) 4 March 31st 09 08:17 AM
Compare two Workbooks and combine data into one workbook SBonner Excel Programming 0 July 13th 06 01:19 AM
Combine multiple workbooks into 1 workbook w/ multiple worksheets buffgirl71 Excel Discussion (Misc queries) 1 May 13th 06 12:28 PM
Combine workbooks into one master workbook. EKB Excel Programming 2 May 6th 06 11:08 AM
Combine multiple workbooks into one workbook Rookie_User Excel Discussion (Misc queries) 0 January 13th 06 06:56 PM


All times are GMT +1. The time now is 12:50 AM.

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"