Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default set up data source of excel spreadsheet

hi all
i have a macrpothat queries a SQL database and this works fine.
i would like to use a similar macro, but to query a table within the
spreadsheet. i do not want to use ms query.

the relevant bits of code from the code i have
:
Public Const ConnectionString = "ODBC;DRIVER=SQL
Server;SERVER=CW0SQL01;DATABASE=MattTest;Trusted_C onnection=Yes;SQL_TXN_ISOLATION=SQL_TXN_READ_UNCOM MITED;SQL_ASYNC_ENABLE=SQL_ASYNC_ENABLE_ON"

--snip--
gsSQLQuery = "This is where query text goes"

With .QueryTables.Add(Connection:=ConnectionString, _
Sql:=gsSQLQuery, Destination:=lWorksheet.Range("A2"))

.Name = "queryoutput1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

---snip-----

i presume i need to set up a connection string within the vb code to
connect to the excel spreadsheet rather than the SQL database - could
someone please give me a clue?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default set up data source of excel spreadsheet

i believe there will be too many variables (5 fields, each of whiuch
has approx 5 potential values, so this gives 5 to the power 5
combinations (3125 columns).
i would like to be able to build an sql query within a vba code as this
will be very fast and keep workbook size very small.

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
Locating Source Data in Master Spreadsheet Jen Excel Discussion (Misc queries) 3 May 27th 10 10:58 PM
Use a different spreadsheet as source data Annette Charts and Charting in Excel 0 September 21st 09 03:29 PM
.xlt does not contain new data from source spreadsheet. JRussell Excel Discussion (Misc queries) 1 April 8th 09 11:58 PM
Use spreadsheet as data source gibbylinks Excel Discussion (Misc queries) 1 July 28th 05 01:08 PM
Setting Spreadsheet control data source to Excel file Lyndsey Excel Programming 0 November 4th 03 05:35 PM


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