#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
Quote:
I realize how to finally do this, and this is what I came up with: Code:
Sub CopyToAnotherWorkbook() ActiveWorkbook.Sheets("Sheet5").ActivateNumRow = Sheets("Sheet5").UsedRange.Rows.CountActiveCell.Select ActiveSheet.Paste End SubWindows("Gerotor Design Studio Results.xlsm").ActivateRange(Cells(1, 1), Cells(NumRow)).SelectSelection.Copy 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. |
Tags |
copy and paste, vba code, workbooks |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 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 |