Copying Ranges Between Workbooks In An Array
Jun 4, 2009
I am trying to copy and paste between workbooks that are defined in an array. However, I get an out of range error when the code first reaches the line Workbooks(Wkbk(WkbkNum)).Activate.
Sub Gather_Risks()
Dim MasterRow As Integer ' Declares row number in Master Worksheet
Dim RowNum As Integer ' Declares row number in active array worksheet
Dim Wkbk(13) As String
MasterRow = 3
WkbkNum = 0
' Declare Wkbk array
Wkbk(0) = "G:Catering-RiskRegister-0409.xls"
Wkbk(1) = "G:CFO-RiskRegister-0409.xls"
Wkbk(2) = "G:Freight-RiskRegister-0409.xls"
Wkbk(3) = "G:GCA-RiskRegister-0409.xls"
Wkbk(4) = "G:IT-RiskRegister-0409.xls"
Wkbk(5) = "G:People-RiskRegister-0409.xls"
Wkbk(6) = "G:Regional-RiskRegister-0409.xls"
StartAgain:
Workbooks.Open (Wkbk(WkbkNum))
RowNum = 3
Do Until WorksheetFunction.CountIf(Rows(RowNum), "") = 0
View 9 Replies
ADVERTISEMENT
Aug 9, 2007
I am creating a macro to copy data from one workbook that is emailed to me to another workbook that contains the actual macro, I will be using the second workbook to import the data into an application.
What I need is to be able to copy text in cells say D1, D3, D6 etc located in workbook1 to cells say A1, A2, A3 etc in workbook2 without having the macro go back and forth each time to copy the cells one at a time.
Also is there a macro that will recognize an already open workbook that I can use to copy the data
View 10 Replies
View Related
Mar 6, 2009
Look in folder and find workbooks with date in name:
Date format is MMDDYYYY
Workbooks have multipule sheets
Look at columns in worksheet E and G.
If E >=10 and G is "ENABLE" copy A:G and
the tab name and paste in the workbook that has
this VB code.
What I am going to do is create a workbook
with a button on Sheet1 and put your code
behind the button that will tackle this great
feet that I do manually that takes about
3 days to do.
View 9 Replies
View Related
Jul 23, 2013
I have a spreadsheet that has a bunch of codes, I want to search all at once in another spreadsheet. If there there I want to copy the data related to that line into my spreadsheet.
Example:
I want to search a long list of items (in column D) in my “work in progress spreadsheet” The program would look into the “Data base spreadsheet” find the “item to search” in the database spreadsheet and copy the “product code” relative to those items, and populate column C with the product codes.
My work in progress spreadsheet
Col C ________________Col D
product codes ________Items to search
....................................G28
....................................G26
....................................F46
....................................J34
Database spreadsheet
Col C __________________Col E
Product codes __________items to search
Product code 16345210 ........J34
Product code 14454685 ........G26
Product code 14587541 ........G28
Product code 15754546 ........F46
View 1 Replies
View Related
Jul 11, 2014
I am working on a project that requires me to copy columns from multiple workbooks to a main one. I am a new comer to VBA what I could come up with gives me an error. Here's where I am right now:
Code:
Sub Import_Click()
Dim MainFile As Workbook
Dim ComFile As Workbook
Dim RDFile As Workbook
Dim UTIFile As Workbook
MainFile = Dir("C:ModelingProcess FilesMain File.xlsm")
ComFile = Dir("C:ModelingProcess FilesModeling - Commercial.xlsx")
[code].....
View 3 Replies
View Related
Dec 17, 2008
I have 194 Workbooks that all contain data on the first sheet only. I need to go into each sheet and pull the information from cell B6 and F21. That information needs to be copied to a new workbook into columns A and B so when I am done I have 194 lines in two columns.
Each of the workbooks I am pulling from have the info I need in Sheet1.
Is this possible, or do I need to do a lot of copying and pasting? If it is possible, how do I do it?
View 9 Replies
View Related
Jul 28, 2009
I have many excel files(nearly 500 in total and growing daily) in a folder called "Results Data" on my C drive. The file names are slightly different (serial numbers). Each excel file contains data in Cells A2:E11. I want to be able to copy only the Cells A2, B4, D5 and E10 from each workbook and paste them into a new workbook, each copied workbook on a new row.
I have been trying to change code that I have found on the web but nothing seems to be working,
View 9 Replies
View Related
Feb 6, 2010
I have a series of workbooks residing in different directories which I am trying to copy into a summary workbook. At present what I did is to open the summary workbook and the individual workbook one by one and copy into the summary workbook by first right clicking of the individual workbook's name tab and select copy to copy onto the summary workbook as a new worksheet. I have about 20 individual workbook to copy and this always take a bit of time every week.
To be a bit clearer, the workbooks are in the following directories and the workbook name and sheet name are shown below. For simplicity sake I will only list 3 of them.
1. D:ContractINF00012301.xls the tab name is 2301
2. D:ContractINF0022403.xls the tab name is 2402
3. D:ContractINF00038400.xls the tab name is 8400
View 9 Replies
View Related
Feb 14, 2009
I am trying to copy columns from one workbook to another workbook as follows:
Source workbook column Destination workbook column
c2:c14 e2:e14
d2:d14 c2:c14
e2:e14 d2:d14
f2:f14 f2:f14
g2:g14 g2:g14
The data columns in both the workbooks are of same length,I just want to copy the corresponding columns from source to destination as per above referenced cells.
How do I write a macro for this?
View 9 Replies
View Related
Jan 15, 2010
I have 2 workbooks formatted the same way.
Using VBA, I want to search through book1 Col A which has a list of Code # s.
If a Code # is in Book 2 Col A, find a match on Book 1 Col A.
After finding a match, compare the range in Book 2 ( Which is the 4 cells immediately to the right ) to the match with the corresponding range in Book 1.
If the range contents are not the same, copy the range from Book2 to Book1 and replace the range in Book1.
If there is NO Match of the Code # in Col A, then Copy the entire row to Book1 and append it to the end of the current Book1 used range.
A MsgBox to show how many changes and additions at the end.
View 11 Replies
View Related
Nov 18, 2006
I'm facing a problem in copying the same ranges from 23 workbooks in the same folder. My code can only work for one workbook.
Dim r As Integer
r = 0
Do
Worksheets("Allocation& Trading").Range("A8").Offset(r, 0).Value = _
Workbooks("July-1").Worksheets(1).Range("A3").Offset(r, 0).Value
r = r + 1
Loop Until Workbooks("July-1").Worksheets(1).Range("A3").Offset(r, 0).Value = ""
I'm required to use the same procedure to copy one of the 23 open workbooks in one time into the worksheets("Allocation&Trading") of another new workbook, which means after using the procedure to copy some ranges from the workbooks("July-1"), I can reuse it to copy the same ranges from the workbooks("July-2") into that same worksheets("Allocation&Trading"). So my procedure has to be flexible enough to work for 23 times for 23 different workbooks in the same folder. Anyone has any idea how to use the same procedure to work for 23 workbooks seperately? I have tried out the codes provided in the similar threads, but they can't solve my problem. Can anyone enlighten me?
View 6 Replies
View Related
May 14, 2008
I have several ranges (i.e. c11:c22, and d11:d22, etc) in an excel spreadsheet that, when the command button is selected, will copy these values into another already established workbook ("aggregator.xls").
Thus, the command button would have to pick each of these ranges and copy them into the aggregator workbook, (i.e. c11:c22 in the first workbook would be copied into b3:b14 in the aggregator workbook; d11:d22 would be copied into b18:b29 in the aggregator workbook, etc.)
In addition, I need it set up so that when the command button is selected to copy this data, that it will look in the aggregator workbook for the next available column for the section that the data will be copied to so that it doesn't write over the previous data.
View 6 Replies
View Related
Feb 2, 2012
I wanted to create a target workbook that is a subset of the source workbook
1) I want to specify a list of worksheets in the source workbook:
For Each WSCurrent In Sheets(Array("SheetA", "SheetB", "SheetC"))
Next WSCurrent
2) I want to them copy these sheets into another workbook (don't know how to code this)
3) I then want to hardcode all these sheets (I don't know the most efficient way to do this)
4) Lastly, I want to eliminate certain columns (can be fed through a hardcoded list of Columns to delete e.g. X, W, Z)
View 5 Replies
View Related
Jan 16, 2014
I have a few hundred workbooks that I am merging into a single file. I found the following vba code that performed this task very well.
Sub simpleXlsMerger()
Dim bookList As Workbook
Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object[code]....
After I merged the data, I realized that I needed to know the source file that each row of information comes from.
How can I modify the above script to copy the filename and add it as an additional column of information when each sheet is copied into the master file?
For Example:
Currently If I have 3 files:
File 1:
1 2 3
4 5 6
File 2:
a b c
d e f
File 3:
v w x
y a b
Running what I currently have will give me:
1 2 3
4 5 6
a b c
d e f
v w x
y a b
View 1 Replies
View Related
Dec 19, 2008
I have a spreadsheet that requires data from different workbooks.But the names of the workbooks are to be received as user input and used dynamically to copy data from that workbook to original workbook.
To make it easier,let me use this example.
I have a workbook named original.xls.It has a command button or any other control.When i click that control it will ask for a workbook name of the project which is in the second column of the "original.xls" workbook.As soon as i enter the workbook name it will copy data from that workbook to the rest of the columns in my "original.xls" workbook.Then it has to ask to ask for second workbook name and do the same procedure till it encounters a blank row.
View 9 Replies
View Related
Feb 27, 2007
1. I have a large number of Test Suites that are large documents with 1 (visible) sheet w/ test cases, and 1 (hidden) sheet w/ validations. Test Suite is saved with a unique name (that follows a naming convention we've set up on this project: <Project>_<Test Suite Category>_<Location in Software>_< date>.xls
2. I need to create a master document in which i can run a macro that will copy each "test suite" sheet from each of these documents, insert it into the master doc, and sort the sheets by name. then it needs to present the data from all of the sheets on the main page of the doc, and break down the results by Test Suite Category, and Location.
Is this possible?
Can I create a macro that will import sheets from (potentially) hundreds of different workbooks, and then sort them appropriately?
I've been looking all over the place, and while i've seen macros that can import specific data, rows, or columns, i havn't quite seen what i'm looking for.
View 9 Replies
View Related
Jun 14, 2007
I've got a variable row length list of data, 24 columns wide with column headers in row 7 and file descriptions on the above rows, that I need to split up into seperate Workbooks dependant upon values in the last column, all rows with the same value in column X form the same new Workbook, which I can then SaveAs with a name associated with the value. I've seen a similar thing done to sheets on the forums by using the Advance Filter and I would adapt that to copy each created worksheet to a new workbook, but a) this seems inefficient and b) my unique values are too long to name sheets from.
View 6 Replies
View Related
Aug 19, 2014
Is there a way to copy multiple ranges and paste the format in the cells below? I tried to use the Union function in the code below:
[Code]....
I was only getting the first column to paste and I don't like all of the select commands. My work around is a lot of lines for a simple command.
[Code] .........
Attached File : Stringing Chart.xlsm
View 1 Replies
View Related
Apr 9, 2014
This should be a fairly simple question, I've already got the code for copying sorted, I'm just curious about several of the named ranges within the sheet and what happens to them when I copy it all over.
I'm working from a spreadsheet made by my predecessor and they've got a template sheet with numerous named rages all scoped to the workbook, on the new template I've created, it has lots of ranges scoped to the sheet itself. The new template works just fine as it is but I just want to try and make sure that when I change over the templates it will continue to work fine and the current template's named ranges are going, so far I have actually copied everything and are running tests, but you can't test for everything, so if the named ranges on the new template being only scoped to the sheet will affect it at all?
View 2 Replies
View Related
Mar 24, 2009
I am using Excel 2003. I have a worksheet called "RawData" which has a continuous list of invoices, I need to separate off the first invoice from the rest of the invoices into a new worksheet and call it "sheet1". The number of rows from cell A1 at the top left corner varies and is never constant from invoice to invoice however the last row of the invoice I need to move always includes the text string "NET PAYABLE TO".
So I need to copy all rows from "A1" to the row that has the text to a new worksheet called "sheet1", I then need to delete those rows only from the original "RawData" worksheet, leaving the remaining invoices in "RawData" intact. If it is helpful to you, the first row on every invoice has the text string "TAX INVOICE".
There are no empty rows between the "NET PAYABLE TO" row at the end of an invoice and the "TAX INVOICE" row at the start of the next invoice, so it is literally a continuous list.
Can this routine then be continued on all the other invoices in "RawData", copying them to new worksheets in the same workbook "sheet2","sheet3" etc until there is no data left in RawData, bearing in mind that there may be 10 invoices or 100 invoices in the "RawData" sheet.
View 9 Replies
View Related
May 31, 2009
I have a file with four worksheets. The first is the master sheet. The other three sheets we can call "SheetB" "SheetC" and "SheetD." The actual names are quite long. Column T of the master sheet (except for the header row) contains dates formatted as text in YYYYMM format. I need a macro that will copy the rows to the other three sheets based on these criteria:
SheetB - dates April 2010 or before
SheetC - dates May 2010 to April 2011
SheetD - dates May 2011 and beyond
View 9 Replies
View Related
Apr 12, 2013
I have timesheets in work, where i created basic formulas to display times & worked hours etc. I also have named ranges on 4 of the sheet.
The sheets are named as the department (area 1, stock control etc.). All the sheets are identical in terms of layout, only the names of staff and hours worked are different.
When i created them, i tried to be pro-active and created flippin loads, through to October this year. Problem being i created a Summary sheet for each workbook, which in short takes all names from all areas and collates them on the last tab, puts Mon-Sun across the top, enters the hours into the relevant days, merges hours worked in different areas and also splits the hours worked over each day.
Everything is working flawlessly.
Except, the above evolution of the sheet was done after i mass created the timesheet, and as such i need to manually open each sheet, set the ranges and name them, add a summary sheet, add the macro, save and close.
Is it possible to create a macro on book1, that when i open however many other workbooks (the actual timesheets) the code would set and name the ranges for me?
The time sheets are all named according to the week -> 'W.C - 08.04.2013', 'W.C - 15.04.2013' etc.
View 1 Replies
View Related
Dec 7, 2008
I want to be able to prompt a user to select a sheet to import to another file. The ranges are as follows.
Sub Importtimesheet()...
View 9 Replies
View Related
Feb 27, 2008
Is there anyway to simplify multiple copy and paste from one workbook to another when there are multiple and different size of data to copy. this is what i have done below. It was a bit tiedious writing it all out
Workbooks("AVA_DA_140906_BPL_SSE_001.csv").Worksheets("AVA_DA_140906_BPL_SSE_001").Activate
Range("E3:G110").Copy
Workbooks("DailyAvailability.xls").Worksheets("Availability").Activate
Range("E17").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks("AVA_DA_140906_BPL_SSE_001.csv").Worksheets("AVA_DA_140906_BPL_SSE_001").Activate
Range("C3: C110").Copy
Workbooks("DailyAvailability.xls").Worksheets("Availability").Activate
Range("H17").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ ...
View 4 Replies
View Related
Dec 14, 2007
For work I have to create copies of the same workbook for every day of the month. I have got the following to do it properly, which may not be the best way so I am open to suggestions, but I don't want it to save this macro in every workbook. There are however other macros that I do want it to take with it, just not this one.
Sub SaveByDate()
Dim a As Integer, b As Integer, c As Integer
' number of days in month + 1 (this is just a test; for Jan a = 32)
a = 6
' start date
b = 1
c = 0
For c = 1 To a
If c < a Then
MyMonth = "Jan"
MyDay = b
MyFileName = MyMonth & " " & MyDay & " 2008 daily report"
ActiveWorkbook.SaveAs Filename:=MyFileName
b = c + 1
End If
Next c
End Sub
View 9 Replies
View Related
Jun 20, 2006
i want to copy data from one excel workbook to other (or ever between diff sheet wud do ) on basis of search on a complete column by picking data one by one from other column & on finding the exact match copy 4 columns form one workbook(or sheet) to other. this has to be done 4 a bulk of data (1000+) so manually is next to impossible.
View 2 Replies
View Related
Apr 25, 2009
There are two sheets: Sheet1 and Sheet2
Columns in Sheet 1 are the following:
company PERMNO number, dates, market capitalization (no data in this one)
Columns in Sheet 2 are the following:
company PERMNO number, ticker, dates, market capitalization
In Sheet2, there is a whole range of dates (between 1990 and 2004) for every single company, whereas in Sheet2 there is one or 3-4 dates for a every single company.
I would like to match the exact date/dates in Sheet1 in the range of dates in Sheet2 and then if they match, copy the corresponding cell value from the market capitalization column in Sheet2 to the empty market capitalization column in Sheet1. I also want that the company PERNO numbers match.
In short: if PERMNO numbers match, match the date/dates in Sheet1 within the range of dates for the same company in Sheet 2 and copy the market capitalization value to Sheet1.
Example:
Sheet1:
A B C
1. PERMNO DATES MARKETCAP
2. 13123 199803
3. 13123 199904
4. 65456 200005
5. 44550 200104
6. 44550 200211......
View 9 Replies
View Related
Apr 22, 2014
Why the following doesn't work?
Sheets("Sheet1").Range(Cells(1,1), Cells(20,1)).Copy Sheets("Sheet2").Range("A1:A20")
If I can get his to work, I will be able to use variables for the Cells arguments to give the functionality I want.
View 3 Replies
View Related
Jul 5, 2014
I want the following script to:
1) Find and define a range ("DateRng") based on cell values. This is controlled by the first block and the script does this job correctly.
2) Find cells
View 1 Replies
View Related
Jun 11, 2007
While copy/pasting large data ranges in Excel, I get the message "Not Enough Memory". I am clearing the clipboard using the command:
Application.CutCopyMode = False
View 4 Replies
View Related