Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-05-2018, 10:44 PM
Josh1012 Josh1012 is offline Copying From One Workbook to Another Workbook Windows 10 Copying From One Workbook to Another Workbook Office 2010 64bit
Novice
Copying From One Workbook to Another Workbook
 
Join Date: Sep 2018
Posts: 12
Josh1012 is on a distinguished road
Default Copying From One Workbook to Another Workbook

Hi,



I'm in the process of copying a lot of data from many workbooks to a master workbook, and I want to see If I can Loop through Each workbook and copy a range of data from 2 different sheets within each workbook back to one sheet in the master workbook. It's taken me days just to copy data and it's a waste of my time and would appreciate any help I can get to write a piece of code that does this.


Also the simple method of using the following code below to copy to another workbook does not work and always follows with an error.



Workbooks("Gerotor Design Studio Results.xlsm").Sheets("Sheet5").Range("A1").Copy _ Destination:=Workbooks("Book1.xlsx").Sheets("Effic iency Map")


Also the workbooks I want to copy data from are essentially in the same format and thus the cell locations do not change which I hope makes it easier.



From the book 1 attachment, I want to copy the flow rates from Sheet("Flow_Pressure") and the Volumetric and Mechanical Efficiency from Sheet("Efficiencies") and then past them into my master workbook("Gerotor Design Studio Results("Master") into Sheet1.





At the moment I've been using the following code to copy the data I want to a new sheet and then manually copying it into my master workbook:


Sub LowToHighSpeedsLowPressures()

Sheets("Flow_Pressure").Range("C4:C9").CopyDestina tion:=Sheets("Sheet5").Range("A1:A6")
Sheets("Flow_Pressure").Range("C10:C15").CopyDesti nation:=Sheets("Sheet5").Range("A17:A22")
Sheets("Flow_Pressure").Range("C16:C21").CopyDesti nation:=Sheets("Sheet5").Range("A33:A38")
Sheets("Flow_Pressure").Range("C22:C27").CopyDesti nation:=Sheets("Sheet5").Range("A49:A54")
Sheets("Flow_Pressure").Range("C28:C33").CopyDesti nation:=Sheets("Sheet5").Range("A65:A70")
Sheets("Flow_Pressure").Range("C34:C39").CopyDesti nation:=Sheets("Sheet5").Range("A81:A86")

Sheets("Efficiencies").Range("C4:C9").CopyDestinat ion:=Sheets("Sheet5").Range("A177:A182")
Sheets("Efficiencies").Range("C10:C15").CopyDestin ation:=Sheets("Sheet5").Range("A193:A198")
Sheets("Efficiencies").Range("C16:C21").CopyDestin ation:=Sheets("Sheet5").Range("A209:A214")
Sheets("Efficiencies").Range("C22:C27").CopyDestin ation:=Sheets("Sheet5").Range("A225:A230")
Sheets("Efficiencies").Range("C28:C33").CopyDestin ation:=Sheets("Sheet5").Range("A241:A246")
Sheets("Efficiencies").Range("C34:C39").CopyDestin ation:=Sheets("Sheet5").Range("A257:A262")

Sheets("Efficiencies").Range("D49").CopyDestinat ion:=Sheets("Sheet5").Range("A333:A338")
Sheets("Efficiencies").Range("D1015").CopyDestin ation:=Sheets("Sheet5").Range("A349:A354")
Sheets("Efficiencies").Range("D1621").CopyDestin ation:=Sheets("Sheet5").Range("A365:A370")
Sheets("Efficiencies").Range("D1015").CopyDestin ation:=Sheets("Sheet5").Range("A381:A386")
Sheets("Efficiencies").Range("D1621").CopyDestin ation:=Sheets("Sheet5").Range("A397:A402")
Sheets("Efficiencies").Range("D1621").CopyDestin ation:=Sheets("Sheet5").Range("A413:A418")

Application.CutCopyMode = False
End Sub
Attached Files
File Type: xlsx Book1.xlsx (24.1 KB, 7 views)
File Type: xlsx Gerotor Design Studio Results.xlsx (350.6 KB, 7 views)
Reply With Quote
  #2  
Old 09-11-2018, 02:48 AM
Josh1012 Josh1012 is offline Copying From One Workbook to Another Workbook Windows 10 Copying From One Workbook to Another Workbook Office 2010 64bit
Novice
Copying From One Workbook to Another Workbook
 
Join Date: Sep 2018
Posts: 12
Josh1012 is on a distinguished road
Default

Quote:
Originally Posted by Josh1012 View Post
I want to see If I can Loop through Each workbook and copy a range of data from 2 different sheets within each workbook back to one sheet in the master workbook.

I realize how to finally do this, and this is what I came up with:


Code:
Sub CopyToAnotherWorkbook()



ActiveWorkbook.Sheets("Sheet5").Activate
NumRow = Sheets("Sheet5").UsedRange.Rows.Count
Range(Cells(1, 1), Cells(NumRow)).Select
Selection.Copy
Windows("Gerotor Design Studio Results.xlsm").Activate
ActiveCell.Select ActiveSheet.Paste End Sub

It's not what I originally wanted but it's easier to automate things I figure with many small macros and just call macro's when you need them. Although I'm not sure if this slows it down.
Reply With Quote
Reply

Tags
copy and paste, vba code, workbooks



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying From One Workbook to Another Workbook Copying a Sheet in a Workbook to Another with Destination-Need Values Instead of Formulas rsrasc Excel Programming 4 08-19-2018 04:00 PM
Sharing a Workbook that contains array formula link to other workbook Ahmad.rage22@gmail.com Excel 0 03-12-2018 10:15 PM
Copying From One Workbook to Another Workbook Copying Every Other Row from one workbook to another. eleno5485 Excel 1 04-07-2017 03:30 PM
data entered in one workbook should be updated in other relevant workbook based on the date vedha Excel 0 04-24-2015 08:45 PM
Range(Cell1,Cell2) Error on another workbook controlling some other workbook? tinfanide Excel Programming 1 02-09-2012 04:08 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft