Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default SELECT ... INTO ... IN ...

Please help if you can

Using the "SELECT ... INTO ... IN ..." statement to import Access data to an
Excel workbook, I only seem to be able to do this

(1) if the Excel workbook is closed and

(2) if the destination worksheet doesn't yet exist.

Is this correct?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default SELECT ... INTO ... IN ...

"Loane Sharp" wrote ...

Using the "SELECT ... INTO ... IN ..." statement to import Access data to an
Excel workbook, I only seem to be able to do this
(1) if the Excel workbook is closed


Correct. Anyhow, using SQL on an open workbook is never a good idea
e.g. with ADO your app will experience a memory leak:

BUG: Memory Leak Occurs When You Query an Open Excel Worksheet Using
ADO
http://support.microsoft.com/default...;en-us;Q319998

(2) if the destination worksheet doesn't yet exist.


Not quite correct. The 'destination' cannot be a worksheet. Rather,
SELECT..INTO (and INSERT INTO..SELECT) creates a workbook-level
defined Name. For example, if my target workbook has only one
worksheet named Sheet2 hosting a workbook-level defined Name named
Sheet1 then

SELECT * INTO [Excel 8.0;Database=C:\MyWorkbook.xls;].Sheet1

will fail because the defined Name Sheet1 already exists. Conversely:

SELECT * INTO [Excel 8.0;Database=C:\MyWorkbook.xls;].Sheet2

will succeed, even though the worksheet Sheet2 exists, because there
is no defined Name named Sheet2. HOWEVER, because a worksheet named
Sheet2 already exists and is not empty, the driver creates a new
worksheet named Sheet21 (following the Excel convention) to host the
new Sheet2 Name.

Jamie.

--
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default SELECT ... INTO ... IN ...

Hi Jamie

Thanks very much

Best regards
Loane
"Jamie Collins" wrote in message
om...
"Loane Sharp" wrote ...

Using the "SELECT ... INTO ... IN ..." statement to import Access data

to an
Excel workbook, I only seem to be able to do this
(1) if the Excel workbook is closed


Correct. Anyhow, using SQL on an open workbook is never a good idea
e.g. with ADO your app will experience a memory leak:

BUG: Memory Leak Occurs When You Query an Open Excel Worksheet Using
ADO
http://support.microsoft.com/default...;en-us;Q319998

(2) if the destination worksheet doesn't yet exist.


Not quite correct. The 'destination' cannot be a worksheet. Rather,
SELECT..INTO (and INSERT INTO..SELECT) creates a workbook-level
defined Name. For example, if my target workbook has only one
worksheet named Sheet2 hosting a workbook-level defined Name named
Sheet1 then

SELECT * INTO [Excel 8.0;Database=C:\MyWorkbook.xls;].Sheet1

will fail because the defined Name Sheet1 already exists. Conversely:

SELECT * INTO [Excel 8.0;Database=C:\MyWorkbook.xls;].Sheet2

will succeed, even though the worksheet Sheet2 exists, because there
is no defined Name named Sheet2. HOWEVER, because a worksheet named
Sheet2 already exists and is not empty, the driver creates a new
worksheet named Sheet21 (following the Excel convention) to host the
new Sheet2 Name.

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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Macro to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 5th 05 12:03 AM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 4th 05 11:59 PM


All times are GMT +1. The time now is 11:24 PM.

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"