Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA and SQL
I have a worksheet that I want to query using SQL. I do not want to
filter the data. This is what I have done so far and I get an error. I have a class modlue "rpt" with dataws defined as a specific sheet in my workbook, wb is the activeworkbook, rptDatabase is the named range I want to query. my conncection string is set up as follows. Do I need to add a reference to make this work and if so which one? I appreciate any help you might have. Public Property Get ConnString() As String ConnString = "Driver={Microsoft Excel Driver (*.xls)};" _ & "DriverId=790;" _ & "Dbq= " & wb.Path & "\" & wb.Name & ";" _ & "DefaultDir=" & wb.Path & "\" & wb.Name End Property Dim mySQL As String Dim qt As QueryTable mySQL = "Select Market, Specialty FROM [rptDatabase] WHERE Market='Ped'" Set qt = rpt.dataws.QueryTables.Add(rpt.ConnString, rpt.dataws.Cells(1, 43), mySQL) qt.Refresh |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|