Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel

ResolvedVersion 2007

Hiral has attended:
Excel VBA Intro Intermediate course

Excel

How to consolidate data of various worksheets from different workbooks into one worksheet ?

RE: Excel data consolidation

Hiral,
We looked at this with the last example of the course: merging data from various source workbooks (Centre1, Centre2, ...) into a single workbook (Consolidated).

The example relies on all the source workbooks having names that can be constructed as "Centre" & i, for i = 1, 2, ..., inside a loop. The body of the loop is:

source_wbname = "Centre " & i & ".xls"
Workbooks.Open (source_wbname) 'Becomes active

ActiveWorkbook.Worksheets("Marks").Copy _
after:=Workbooks(destination_wbname).Worksheets(wscount)

Workbooks(source_wbname).Close 'This workbook becomes active

ActiveWorkbook.Worksheets("Marks").Name = "Centre " & i

wscount = wscount + 1
i = i + 1

We used the file-not-found error to jump out of the loop - again, see the notes.

Note that when using multiple workbooks, life is simpler if they are all in the same folder on disk.

Hope this helps,
/Roy MacLean

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Use Paint Brush to Format More than one Cell

To copy a format to many cells or ranges

1. Select the cell with the format that you want to copy

2. Double-click on the paint brush

When you move to the cell where you want to paste the format you will notice that a paint brush follows the cursor.

Paste the format to all the cells or ranges you need to format.

When finished go back to the paint brush on the tool bar and single click on it to deactivate the function.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.11 secs.