PC Review


Reply
Thread Tools Rate Thread

COMBINING WORKBOOKS

 
 
lmarstin
Guest
Posts: n/a
 
      24th Jun 2008
I have 32 workbooks with 3 worksheets each. Each worksheet in each workbook
is named the same. I need to combine all 32 workbooks into one files with
each of the 3 sheets moved. This will make for a total of 96 sheets. I
really don't want to have to open each file and copy the worksheets to a
master sheet.
 
Reply With Quote
 
 
 
 
cush
Guest
Posts: n/a
 
      24th Jun 2008
Try something like:

Option Explicit

Sub CopySheets()
Dim Wb As Workbook
Dim i As Integer
Dim j As Integer

On Error Resume Next
''GET THE FIRST WB
Set Wb = Workbooks.Open(Dir(ThisWorkbook.Path & "\*.xls"))
For i = 1 To 3
Wb.Sheets(i).Copy After:=ThisWorkbook.Sheets(1)
Next i
Wb.Close False

''GET REMAINING WBKS
For j = 1 To 32
If Wb.Name <> ThisWorkbook.Name Then
Set Wb = Workbooks.Open(Dir)
For i = 1 To 3
Wb.Sheets(i).Copy After:=ThisWorkbook.Sheets(1)
Next i
Wb.Close False
End If
Next j

Set Wb = Nothing

End Sub

"lmarstin" wrote:

> I have 32 workbooks with 3 worksheets each. Each worksheet in each workbook
> is named the same. I need to combine all 32 workbooks into one files with
> each of the 3 sheets moved. This will make for a total of 96 sheets. I
> really don't want to have to open each file and copy the worksheets to a
> master sheet.

 
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
Combining Workbooks =?Utf-8?B?Um9ubmllRg==?= Microsoft Excel Charting 0 17th May 2007 08:40 PM
Combining Workbooks =?Utf-8?B?YmFuam9yZWFk?= Microsoft Excel Misc 4 14th Nov 2006 03:56 PM
Combining 3 workbooks to one =?Utf-8?B?U0lUQ0ZhblRO?= Microsoft Excel Programming 4 23rd Oct 2006 11:56 PM
combining many different workbooks =?Utf-8?B?d2hhdCB3ZXJlIHRoZXkgdGhpbmtpbmc=?= Microsoft Excel Misc 1 14th Jan 2006 09:05 AM
Combining 2 workbooks Kayth Microsoft Excel Worksheet Functions 2 24th May 2004 10:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:43 PM.