Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
DSUM Basics | Excel Discussion (Misc queries) | |||
basics? | New Users to Excel | |||
Excel Basics | Excel Discussion (Misc queries) | |||
Excel VBA basics | Excel Programming | |||
Help with the basics. Starting out. | Excel Programming |