Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 12
Default data disappear after extracting from querytable

In worksheet("source"), there are around 10000 rows and 12 columns (fields).
All columns in worksheet("source") are going to be pasted on
worksheet("target") using the following codes. I have also simplified the
query which actually involved more complicated calculations.
Columns A to H: all rows have data
Columns I to L: the first 6000 rows are blank

The problem is that I could only extract the data from Columns A to H, but
not Columns I to L which are ALL BLANK. Also, all fieldnames from Col. A to
Col. L can be extracted correctly to row1 of worksheet("target")...
The most strange thing is that if I do not leave the the first row blank
(e.g. leave only Col. J, K & L blank, and input '1' in cell(I2), then Col. I
will be extracted correctly...

Can anyone help?
Thanks a lot!!

__________________________________________________ ________________________________
Sub test()

Dim varConn As String, varSql As String
Dim varQry As QueryTable

Worksheets("target").Columns.Delete

varConn = "ODBC;DefaultDir=C:\Work;driver={Microsoft Excel Driver
(*.xls)};DriverId=790;dbq=C:\Work\testDB.xls"

varSql = "SELECT * from [source$]"

Set varQry = Worksheets("target").QueryTables.Add(Connection:=v arConn,
Destination:=Worksheets("target").Range("a1"), Sql:=varSql)
varQry.BackgroundQuery = False
varQry.Refresh

End Sub


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
Update querytable connections and refresh data Dale Fye Excel Discussion (Misc queries) 0 November 2nd 07 03:46 PM
Update querytable connections and refresh data Dale Fye Charts and Charting in Excel 0 November 2nd 07 03:46 PM
Update querytable connections and refresh data Dale Fye Excel Programming 0 November 2nd 07 03:46 PM
Changing a QueryTable data source Mike Jones Excel Programming 3 May 5th 05 02:20 PM
Using Querytable.add to import data from a closed workbook Markus Stolle[_5_] Excel Programming 8 August 3rd 04 08:51 PM


All times are GMT +1. The time now is 01:21 PM.

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"