Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
WBTKbeezy
 
Posts: n/a
Default Multiple Pastes Between workbooks

I have 3 workbooks, each contains the same 30 tabs, but each workbook
contains different information. There is a main workbook, and two extra with
information that I need to put all together on the main workbook. I am
looking for the easiest way to paste the info from the 2 workbooks into the
main work book without having to do it tab by tab and workbook by workbook.
Anyone have any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
broro183
 
Posts: n/a
Default Multiple Pastes Between workbooks


Hi,
I'm hoping that you know how to use macros, if not, you may find the
link below useful:
( http://www.mvps.org/dmcritchie/excel/getstarted.htm )

1 Open all three files.
2 Copy the macro below into a module of the VBA project of your main
workbook (in Excel press [ALT + F11] (this opens the VB Editor), right
click on the VBA project of your file, Insert-Module).
3 Paste the code below into the resulting sheet that appears.
4 Change the file names in the appostrophes (as commented), change the
ranges as required & run the macro by placing the cursor within the
code .
Please note:
* may have word wrapping (the space & underscore, ie " _") in the wrong
places,
* that the below does not include error handling,
* hasn't been tested for speed or handling of large data sets,
* will over write any data that exists in the destination cells of the
main workbook,
* and most of all, requires all the sheet names to be exactly the same
in each of the 3 workbooks.

Sub CopyThirtyTabs()
Dim CopiedFrom1 As String
Dim CopiedFrom2 As String
Dim MainWorkbook As Workbook
Dim ws As Worksheet
Dim i As Long
Dim DataSheetName() As String

CopiedFrom1 = "copiedfrom1.xls" 'change file name as needed
CopiedFrom2 = "copiedfrom2.xls" 'change file name as needed
Set MainWorkbook = ThisWorkbook

' Store the sheet names as separate strings
ReDim DataSheetName(1 To 30) 'The # of tabs
For Each ws In MainWorkbook.Worksheets
i = i + 1
DataSheetName(i) = ws.Name
Next ws

'Copies selected data from each of the workbooks into the main one for
_
each of the 30 sheets.
For i = 1 To 30

Workbooks(CopiedFrom1).Worksheets(DataSheetName(i) ).Range("a1:b10").Copy
_
MainWorkbook.Worksheets(DataSheetName(i)).Range("a 1:b10")


Workbooks(CopiedFrom2).Worksheets(DataSheetName(i) ).Range("a1:b10").Copy
_
MainWorkbook.Worksheets(DataSheetName(i)).Range("c 1:d10")
'Note the different destination range for pasting into on the
second copy.
Next i
MsgBox "all done :-)"
End Sub


btw, Another similar thread may also help you:
http://excelforum.com/showthread.php...hlight=started

hth
Rob Brockett
NZ
Always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=526139

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
AHHHH-Get Data from Multiple Excel workbooks JAA149 Excel Discussion (Misc queries) 5 October 30th 05 05:19 PM
Combine contents of multiple workbooks into one worksheet EMG03 Excel Worksheet Functions 1 October 25th 05 12:15 AM
Macro that will add data from multiple workbooks to the 1st open r jbsand1001 Excel Discussion (Misc queries) 0 April 23rd 05 07:52 PM
linking to multiple workbooks cwwolfdog Excel Discussion (Misc queries) 4 April 18th 05 05:29 PM
adding certain cells in multiple worksheets in multiple workbooks Stephen via OfficeKB.com Excel Worksheet Functions 1 February 4th 05 08:31 PM


All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"