Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default QueryTable Basics..

I am trying to assign a range of cells to a query table.
But am not able to do it..
The data is in a Sheet called "MasterData" not sure where to specify
that..
Also when i run the query, is it possible to get the data (In an array
or RecordSet) and do some formatting before it is displayed...

The below code returns a 1004 error..not sure why..

Thanks in Anticipation
Thiaga

Public Sub test21()
Dim dbqPath As String
Dim qtb As QueryTable
Const qtbName As String = "MyQueryTable"
Const strCnn As String = "ODBC;Driver={Microsoft Excel
Driver(*.xls)};DriverId=790;"
Dim strSQL As String
Dim targetSh As Worksheet

strSQL = "SELECT * FROM MyQueryTable"
dbqPath = ThisWorkbook.FullName
Set targetSh = ThisWorkbook.Sheets("Work Effort Summary")
Set rng = targetSh.Range("B15")
With targetSh
With .QueryTables.Add(Connection:=strCnn & "DBQ=" & dbqPath &
";", _
Destination:=rng, Sql:=strSQL)
.Name = qtbName
.FieldNames = True
.Refresh
End With
End With
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
DSUM Basics Midland Excel Discussion (Misc queries) 1 August 26th 09 06:15 PM
basics? n21 New Users to Excel 7 September 21st 06 12:37 PM
Excel Basics gallegos1580 Excel Discussion (Misc queries) 2 January 7th 05 06:45 PM
Excel VBA basics Philipp Excel Programming 3 October 11th 04 10:11 AM
Help with the basics. Starting out. beeawwb Excel Programming 2 January 9th 04 12:17 AM


All times are GMT +1. The time now is 02:17 AM.

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"