View Single Post
  #14   Report Post  
GrayesGhost
 
Posts: n/a
Default

JV,

Thanks for the info, but that is a little too complicated for me. I'm doing
a very simple operation and it would take me longer to learn and implement
those formulas than it would for me to simply open the old workbook, do a
copy/paste, then close and delete the source file.

Take Care - GG

"JVLin" wrote:

Hi,

I posted a similar question a few weeks ago on the programming part of this
forum.

I got this answer from Jamie Collins:

can I copy data from one workbook to another (or for that matter
from within a workbook) WITHOUT OPENING EACH WORKBOOK?


If your data is arranged as a database (i.e. rows of columns,
preferable with column headers) then yes.

A simple example to copy the entire contents of one table (worksheet)
to another workbook where the table does not already exist:

SELECT
MyKeyCol, MyDataCol
INTO
[Excel 8.0;HDR=YES;Database=C:\My
Folder\MyTargetWorkbook.xls;].[Sheet8$]
FROM
[Excel 8.0;HDR=YES;Database=C:\My
Folder\MySourceWorkbook.xls;].[Sheet8$]
;

A more complex example where the table does already exist in the
target workbook and you only want to append non-duplicated rows:

INSERT INTO
[Excel 8.0;HDR=YES;Database=C:\My
Folder\MyTargetWorkbook.xls;].[Sheet8$]
(MyKeyCol, MyDataCol)
SELECT
T1.MyKeyCol, T1.MyDataCol
FROM
[Excel 8.0;HDR=YES;Database=C:\My
Folder\MySourceWorkbook.xls;].[Sheet8$] T1
LEFT JOIN
[Excel 8.0;HDR=YES;Database=C:\My
Folder\MyTargetWorkbook.xls;].[Sheet8$] T2
ON T1.MyKeyCol=T2.MyKeyCol
WHERE
T2.MyKeyCol IS NULL
;


I have to admit this code is too complicated for me, but perhaps you can
find some use for it. If not: perhaps you can ask Jamie to explain!

JvLin

PS The question I posed also pertained to getting a collection of worksheet
names from unopened workbooks.