Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Add data from another spreadsheet

I currently export data in the form of two seperate spreadsheets from two
different Access databases. The data contained in each spreadsheet is simply
two columns (costweek/year and total hours).
I would like to combine these spreadsheets by taking one of the spreadsheets
and adding a third column which contains the hours from the second
spreadsheet corresponding to the costweek/year number.
Sorry if this is the wrong discussion group for this 'problem'.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Add data from another spreadsheet

TerryM wrote ...

I currently export data in the form of two seperate spreadsheets from two
different Access databases. The data contained in each spreadsheet is simply
two columns (costweek/year and total hours).
I would like to combine these spreadsheets by taking one of the spreadsheets
and adding a third column which contains the hours from the second
spreadsheet corresponding to the costweek/year number.


IMHO better to combine the data *before* it gets to Excel. Jet (MS
Access) does not support the SQL-92 FULL OUTER JOIN syntax so we have
to use the UNION between a LEFT- and a RIGHT OUTER JOIN. Something
like:

SELECT
DT1.cost_date, DT1.TotalHours_DB1,
DT1.TotalHours_DB2
INTO
[Excel 8.0;Database=C:\MyWorkbook.xls].MyExcelTable
FROM (
SELECT
T1.cost_date,
T1.hours_total AS TotalHours_DB1,
T2.hours_total AS TotalHours_DB2
FROM
[Database=C:\DB1.mdb;].MyTable AS T1
LEFT JOIN [Database=C:\DB2.mdb;].MyTable AS T2
ON T1.cost_date = T2.cost_date
UNION
SELECT
T2.cost_date,
T1.hours_total AS TotalHours_DB1,
T2.hours_total AS TotalHours_DB2
FROM
[Database=C:\DB1.mdb;].MyTable AS T1
RIGHT JOIN [Database=C:\DB2.mdb;].MyTable AS T2
ON T1.cost_date = T2.cost_date
) AS DT1
ORDER BY
DT1.cost_date
;

Jamie.

--
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Add data from another spreadsheet

Thanks I'll certainly try that. To be honest it never even crossed my mind to
do it that way. Once again thanks.

Terry

"Jamie Collins" wrote:

TerryM wrote ...

I currently export data in the form of two seperate spreadsheets from two
different Access databases. The data contained in each spreadsheet is simply
two columns (costweek/year and total hours).
I would like to combine these spreadsheets by taking one of the spreadsheets
and adding a third column which contains the hours from the second
spreadsheet corresponding to the costweek/year number.


IMHO better to combine the data *before* it gets to Excel. Jet (MS
Access) does not support the SQL-92 FULL OUTER JOIN syntax so we have
to use the UNION between a LEFT- and a RIGHT OUTER JOIN. Something
like:

SELECT
DT1.cost_date, DT1.TotalHours_DB1,
DT1.TotalHours_DB2
INTO
[Excel 8.0;Database=C:\MyWorkbook.xls].MyExcelTable
FROM (
SELECT
T1.cost_date,
T1.hours_total AS TotalHours_DB1,
T2.hours_total AS TotalHours_DB2
FROM
[Database=C:\DB1.mdb;].MyTable AS T1
LEFT JOIN [Database=C:\DB2.mdb;].MyTable AS T2
ON T1.cost_date = T2.cost_date
UNION
SELECT
T2.cost_date,
T1.hours_total AS TotalHours_DB1,
T2.hours_total AS TotalHours_DB2
FROM
[Database=C:\DB1.mdb;].MyTable AS T1
RIGHT JOIN [Database=C:\DB2.mdb;].MyTable AS T2
ON T1.cost_date = T2.cost_date
) AS DT1
ORDER BY
DT1.cost_date
;

Jamie.

--

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
Collate data from one spreadsheet into another spreadsheet Anthony Excel Worksheet Functions 2 October 19th 09 05:19 PM
Linking 2 spreadsheet using data from the last row of spreadsheet Mike Excel Discussion (Misc queries) 13 February 11th 09 10:48 AM
Can I pull data from a spreadsheet to another spreadsheet Pat Excel Discussion (Misc queries) 2 March 18th 07 10:22 PM
How do I copy spreadsheet data as shown to another spreadsheet? trainer07 Excel Discussion (Misc queries) 2 August 7th 06 09:39 PM
How to open another Excel spreadsheet to copy data into current spreadsheet ? Ricky Pang Excel Programming 0 July 13th 03 01:59 PM


All times are GMT +1. The time now is 10:41 AM.

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

About Us

"It's about Microsoft Excel"