#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Destination range

Rows 1,2,3 have input controls for the user.
When I execute the following, it is supposed to return the data to range=A4,
instead, it inserts 5 columns of data at A1.

Private Sub CommandButton1_Click()
' do query using dates from B1, B2
' NOTE: need to adjust dates by subtracting 36161 to match up with date
values

Dim qt As QueryTable

sqlstring = "SELECT INVOICE, CUSTOMERNAME, ITEM_REC, QUANTITY, AMOUNT FROM
TRANSACT"
connstring = "ODBC;DSN=Odyssey"
Set qt = ActiveSheet.QueryTables.Add(Connection:=connstring ,
Destination:=ActiveSheet.Range("A4"))
qt.FillAdjacentFormulas = True
qt.CommandText = sqlstring
qt.CommandType = xlCmdSql
qt.Destination.ClearContents
qt.Refresh
End Sub

How do I get it to return the results to the location I specify?

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
Duplicate Range Names by worksheet FlaAl Excel Discussion (Misc queries) 0 May 24th 06 05:14 PM
checking that cells have a value before the workbook will close kcdonaldson Excel Worksheet Functions 8 December 5th 05 04:57 PM
Help with using range names in sum function soteman2005 Excel Worksheet Functions 2 November 28th 05 04:43 PM
can a formula check for a certain value in a range? Lee IT Excel Discussion (Misc queries) 1 April 7th 05 04:31 PM
Counting empty cells within a range of cells Rosehill - ExcelForums.com New Users to Excel 0 April 7th 05 12:47 AM


All times are GMT +1. The time now is 03:09 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"