Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ajd ajd is offline
external usenet poster
 
Posts: 16
Default Copying Worksheets in Different Books to One Workbook

I have a list of Workbook paths and adjacent to it a list of Worksheets. I
want to copy the listed worksheets which are all in different workbooks into
a single, new workbook. This is the code I have so far:

Sub MasterBook()

ActiveWorkbook.Sheets("Master").Select
Cells.Select
Selection.Copy
Set wso = Application.Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=Fasle, Transpose:=False
RowCount = 11
Do While Range("A" & RowCount) < ""
If Range("D" & RowCount) = "yes" Then
Set BookName = Range("L" & RowCount)
Set SheetName = Range("M" & RowCount)
Workbooks(BookName).Sheets(SheetName).Copy Befo=wso.Sheets(1)
End If

RowCount = RowCount + 1
Loop

End Sub

Range L has the workbook name in the form of a full file path. The file
path has worked for another macro which I used to create that file. Range M
has the worksheet name. In column D is where I identify whether I want to
bring in that specific sheet or not. It's getting hung up in the
Workbooks(BookName)... line with a type mismatch.

Please help with this code or suggest an alternative way of doing this.
Thank you very much for your help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Copying Worksheets in Different Books to One Workbook

You can certainly do this, but you'll have to put in a little time to get it
right. Look at these resources:
http://www.rondebruin.nl/copy2.htm
http://www.rondebruin.nl/copy3.htm
http://www.rondebruin.nl/fso.htm

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ajd" wrote:

I have a list of Workbook paths and adjacent to it a list of Worksheets. I
want to copy the listed worksheets which are all in different workbooks into
a single, new workbook. This is the code I have so far:

Sub MasterBook()

ActiveWorkbook.Sheets("Master").Select
Cells.Select
Selection.Copy
Set wso = Application.Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=Fasle, Transpose:=False
RowCount = 11
Do While Range("A" & RowCount) < ""
If Range("D" & RowCount) = "yes" Then
Set BookName = Range("L" & RowCount)
Set SheetName = Range("M" & RowCount)
Workbooks(BookName).Sheets(SheetName).Copy Befo=wso.Sheets(1)
End If

RowCount = RowCount + 1
Loop

End Sub

Range L has the workbook name in the form of a full file path. The file
path has worked for another macro which I used to create that file. Range M
has the worksheet name. In column D is where I identify whether I want to
bring in that specific sheet or not. It's getting hung up in the
Workbooks(BookName)... line with a type mismatch.

Please help with this code or suggest an alternative way of doing this.
Thank you very much for your help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
ajd ajd is offline
external usenet poster
 
Posts: 16
Default Copying Worksheets in Different Books to One Workbook

I was able to adapt that to generally achieve what I was looking for. Thanks.

"ryguy7272" wrote:

You can certainly do this, but you'll have to put in a little time to get it
right. Look at these resources:
http://www.rondebruin.nl/copy2.htm
http://www.rondebruin.nl/copy3.htm
http://www.rondebruin.nl/fso.htm

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ajd" wrote:

I have a list of Workbook paths and adjacent to it a list of Worksheets. I
want to copy the listed worksheets which are all in different workbooks into
a single, new workbook. This is the code I have so far:

Sub MasterBook()

ActiveWorkbook.Sheets("Master").Select
Cells.Select
Selection.Copy
Set wso = Application.Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=Fasle, Transpose:=False
RowCount = 11
Do While Range("A" & RowCount) < ""
If Range("D" & RowCount) = "yes" Then
Set BookName = Range("L" & RowCount)
Set SheetName = Range("M" & RowCount)
Workbooks(BookName).Sheets(SheetName).Copy Befo=wso.Sheets(1)
End If

RowCount = RowCount + 1
Loop

End Sub

Range L has the workbook name in the form of a full file path. The file
path has worked for another macro which I used to create that file. Range M
has the worksheet name. In column D is where I identify whether I want to
bring in that specific sheet or not. It's getting hung up in the
Workbooks(BookName)... line with a type mismatch.

Please help with this code or suggest an alternative way of doing this.
Thank you very much for your help!

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
Copying Worksheets from one workbook to another Ronald R. Dodge, Jr.[_2_] Excel Programming 8 March 11th 08 02:13 PM
copying all worksheets into one workbook JLGWhiz Excel Programming 0 March 27th 07 11:29 PM
copying worksheets to a new workbook without formulae referencing original workbook [email protected] Excel Programming 2 October 16th 06 07:31 PM
Copying worksheets to a new workbook csimont Excel Discussion (Misc queries) 4 February 8th 06 08:44 PM
Trouble copying worksheets between books - is there size limit? kris2u Excel Worksheet Functions 2 October 13th 05 08:44 PM


All times are GMT +1. The time now is 07:22 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"