Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Getting external data from multiple excel workbooks

Hi everyone,

I would like to use Get external data in the Data tab to query data from
mulitple workbooks. By doing so, i supposed, there is no need to open the
workbooks and still get the data that i would like to have. The data from
these workbooks appears in the same format but it is not in a template/table
form.

However, I can only manage to query from a single file. How do I query and
collate all the data from mulitple excel files into a single worksheet?

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Getting external data from multiple excel workbooks

You can use MS Query to consolidate Excel ranges from your
multiple wkbks/wkshts. This also works for consolidating data from the
active workbook (Just save it first so Excel can find it):

This example uses 5 named ranges in 5 different workbooks.
(Each range contain 4 columns: Dept, PartNum, Desc, Price)

Assumptions:
The data in each wkbk is structured like a table:
---Col headings (Dept, PartNum, Desc, Price)
---Columns are in the same order.

The data in each wkbk must be in named ranges.
---I used rng1111Data for dept 1111's data, rng2222Data for dept 2222, etc
---You may use the same range name in different wkbks.

(Note: MS Query may display warnings about it's ability to show the query
....ignore them and proceed.)

Starting with an empty worksheet:
1)Select the cell where you want the consolidated data to start

2)DataImport External DataNew Database Query
Databases: Excel Files


Browse to one of The files, pick The data range to import.
---Accept defaults until the next step.

At The last screen select The View data/Edit The Query option.

Click the [SQL] button

Replace the displayed SQL code with an adapted version of this:

SELECT * FROM `C:\Dept1111`.rng1111Data
UNION ALL
SELECT * FROM `C:\Dept2222`.rng2222Data
UNION ALL
SELECT * FROM `C:\Dept3333`.rng3333Data
UNION ALL
SELECT * FROM `C:\Dept5555`.rng4444Data
UNION ALL
SELECT * FROM `C:\Dept5555`.rng5555Data

(Note: the apostrophes in the SQL code ( ` )are located on the same key as
the tilde (~) )
Return the data to Excel.

Once that is done....to get the latest data just click in the data range
then DataRefresh Data.
(You can edit the query at any time to add/remove data sources and/or fields.)


Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Dean C" wrote:

Hi everyone,

I would like to use Get external data in the Data tab to query data from
mulitple workbooks. By doing so, i supposed, there is no need to open the
workbooks and still get the data that i would like to have. The data from
these workbooks appears in the same format but it is not in a template/table
form.

However, I can only manage to query from a single file. How do I query and
collate all the data from mulitple excel files into a single worksheet?

Thanks in advance!

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,123
Default Getting external data from multiple excel workbooks

Maybe you can use my ADO example
http://www.rondebruin.nl/ado.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dean C" wrote in message ...
Hi everyone,

I would like to use Get external data in the Data tab to query data from
mulitple workbooks. By doing so, i supposed, there is no need to open the
workbooks and still get the data that i would like to have. The data from
these workbooks appears in the same format but it is not in a template/table
form.

However, I can only manage to query from a single file. How do I query and
collate all the data from mulitple excel files into a single worksheet?

Thanks in advance!

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Getting external data from multiple excel workbooks

Hi Ron, I found your answer which is perfect for something I need to do but
.... I need just one further hep: how can I add a specific field in SQL with a
text, for example the file's name.

I tried something like:

SELECT range.*, "Text" as Heading FROM `excel file name`.range

but does not work... can you pls help me out? thanks. Kind regards.

Santiago

"Ron Coderre" wrote:

You can use MS Query to consolidate Excel ranges from your
multiple wkbks/wkshts. This also works for consolidating data from the
active workbook (Just save it first so Excel can find it):

This example uses 5 named ranges in 5 different workbooks.
(Each range contain 4 columns: Dept, PartNum, Desc, Price)

Assumptions:
The data in each wkbk is structured like a table:
---Col headings (Dept, PartNum, Desc, Price)
---Columns are in the same order.

The data in each wkbk must be in named ranges.
---I used rng1111Data for dept 1111's data, rng2222Data for dept 2222, etc
---You may use the same range name in different wkbks.

(Note: MS Query may display warnings about it's ability to show the query
...ignore them and proceed.)

Starting with an empty worksheet:
1)Select the cell where you want the consolidated data to start

2)DataImport External DataNew Database Query
Databases: Excel Files


Browse to one of The files, pick The data range to import.
---Accept defaults until the next step.

At The last screen select The View data/Edit The Query option.

Click the [SQL] button

Replace the displayed SQL code with an adapted version of this:

SELECT * FROM `C:\Dept1111`.rng1111Data
UNION ALL
SELECT * FROM `C:\Dept2222`.rng2222Data
UNION ALL
SELECT * FROM `C:\Dept3333`.rng3333Data
UNION ALL
SELECT * FROM `C:\Dept5555`.rng4444Data
UNION ALL
SELECT * FROM `C:\Dept5555`.rng5555Data

(Note: the apostrophes in the SQL code ( ` )are located on the same key as
the tilde (~) )
Return the data to Excel.

Once that is done....to get the latest data just click in the data range
then DataRefresh Data.
(You can edit the query at any time to add/remove data sources and/or fields.)


Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Dean C" wrote:

Hi everyone,

I would like to use Get external data in the Data tab to query data from
mulitple workbooks. By doing so, i supposed, there is no need to open the
workbooks and still get the data that i would like to have. The data from
these workbooks appears in the same format but it is not in a template/table
form.

However, I can only manage to query from a single file. How do I query and
collate all the data from mulitple excel files into a single worksheet?

Thanks in advance!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Matching Button for MS Excel 2007 or later Mr. Low Excel Worksheet Functions 0 October 21st 06 10:07 AM
Multiple workbooks on Taskbar in Excel 97 S Dees Excel Discussion (Misc queries) 5 April 19th 06 08:04 PM
Update External Data source from Excel sheet Lara Jacobs Excel Discussion (Misc queries) 2 March 28th 06 07:17 AM
From several workbooks onto one excel worksheet steve Excel Discussion (Misc queries) 6 December 1st 05 08:03 AM
External data Macro Problem Excel 97 Craig Kelly Excel Discussion (Misc queries) 1 January 17th 05 03:17 PM


All times are GMT +1. The time now is 01:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"