Consolidate workbooks into one workbook

asudevils5150

New Member
Joined
Feb 19, 2002
Messages
49
Is there a macro to conslidate let's say 3 workbooks into one workbook. Also, let's assume the each workbook has 5 sheets within each book. I'd like to have the new workbook have each sheet separately. Then I have a macro to combine each sheet into one sheet. Ultimately, I'd like to consolidate each worksheet from various workbooks into one master sheet (within a new workbook).

Any help is greatly appreciated
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Do you only want to copy values or formula , formats , etc ??
Do you want blanks in the source skipped ?
Are the values in the source all constants or are some based on formula ?
Do all columns of data start in column A ?
 
Upvote 0
Let's assume all the data start in column A, but some sheets can end in column E, some in F, etc.

I just want to copy the values, no formulas.

All the data, let's assume is values, no formulas at all

I just want to copy the data, no blanks, so this may cause diffuculty since some rows have 500 rows, and some sheets have 1000 rows.

I guess if i have to copy over blank rows, i can sort the data once all together, then sort the blank rows out. I have the macro to consolidate all the sheets once they are in the some workbook. I just need to get to that step
 
Upvote 0
Ok ... one more question and then we can program the code ...
Would you like the data offset by one column so that column A can be used to ID source of data ?

In other words move all data over by one column in the Target sheet and use Column A , in target sheet , to indicate what book and what sheet that the data came from ??? Once you done looking at column A all you would need to do is delete it and all data would be where it belongs . :wink:
 
Upvote 0
This code will copy all open workbooks into the activeWorkBooks ActiveSheet.
The Active Workbook must be where the code is and will not be included in the copy process.
This version does not give you a "Tracking Column" .. please let me know if you would like code modified to provide a tracking column.

Sub CopyAllOpenBooks()
Dim Sh As Worksheet
Dim Wb As Workbook
For Each Wb In Workbooks
If Not Wb.Name = ThisWorkbook.Name Then
For Each Sh In Wb.Worksheets
Sh.Range(("A1:" & Sh.Cells.SpecialCells(xlCellTypeLastCell).Address)).Copy
Range("A" & Cells.SpecialCells(xlCellTypeLastCell).Row + 1).PasteSpecial Paste:=xlPasteValues
Next Sh
End If ' WB name not this one
Next Wb
End Sub

OTHER QUESTIONS:
1. Is this a process you will need to do on a regular basis ? If so this could be set up to run automatically on a set of workbooks without the books even being opened. For example you could have the code look for all XLS books in a certain directory and get all the data imported without having to open anything but the target sheet. :wink:
 
Upvote 0
I don't think I'll need a "target" column, but thanks for asking. I'll test the subroutine now to see if it works. Thanks so much
 
Upvote 0
Actually, now that I think about it, what would be the code to include a source column and also to combine the books from a directory containing XLS files? Thanks!! The code works. This saves me a lot of time
 
Upvote 0
what part of the code do I take out regarding that "Column D" routine? Again, thanks again on the previous code.

By the way, on the previous code you provided call "CopyAllBooks", what would the code be to get rid of blank rows and columns / or blank cells and "mush" them altogther.

For instance, let's say on Sheet 1, i have data from A1:A5, then data again on A10, then the next row is on row C. Anyway to make the data cram from A1:A6, then row B? Just a thought...
 
Upvote 0
asudevils5150

Do you want to get rid of "both" blank rows and columns ? I'm thinking you may just want to get rid of blank rows. If you get rid of blank columns then data would get moved from column to column. Eg. you have data in your source in ColA and ColC .. if your remove blanks in columnB then final data would reside in ColA and ColB instead of the original ColA and ColC.
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top