PC Review


Reply
Thread Tools Rate Thread

data disappear after extracting from querytable

 
 
guy
Guest
Posts: n/a
 
      22nd Nov 2007
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:=varConn,
Destination:=Worksheets("target").Range("a1"), Sql:=varSql)
varQry.BackgroundQuery = False
varQry.Refresh

End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update querytable connections and refresh data Dale Fye Microsoft Excel Programming 0 2nd Nov 2007 03:46 PM
Update querytable connections and refresh data Dale Fye Microsoft Excel Misc 0 2nd Nov 2007 03:46 PM
Update querytable connections and refresh data Dale Fye Microsoft Excel Charting 0 2nd Nov 2007 03:46 PM
Changing a QueryTable data source Mike Jones Microsoft Excel Programming 3 5th May 2005 02:20 PM
Using Querytable.add to import data from a closed workbook Markus Stolle Microsoft Excel Programming 8 3rd Aug 2004 08:51 PM


Features
 

Advertising
 

Newsgroups
 


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