Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'
With ActiveSheet.ListObjects(1).QueryTable
Debug.Print .Connection
Debug.Print .Sql
End With
Sub ChangeQT_ThisWorkbookPath()
Dim sPath As String, sDB As String
Dim sConn As String, sSQL As String
sPath = ThisWorkbook.Path
sDB = ThisWorkbook.Name
'ODBC;DSN=Excel Files;
'DBQ=C:\Users\Skip\Documents\2016PharmacyAnalysis.xlsx;
'DefaultDir=C:\Users\Skip\Documents;
'DriverId=1046;MaxBufferSize=2048;PageTimeout=5;
sConn = sConn & "ODBC;DSN=Excel Files;"
sConn = sConn & "DBQ=" & [color #204A87]sPath[/color] & "\" & [color #204A87]sDB[/color] & ";"
sConn = sConn & "DefaultDir=" & [color #204A87]sPath[/color] & ";"
sConn = sConn & "DriverId=1046;MaxBufferSize=2048;PageTimeout=5;"
With ActiveSheet.ListObjects(1).QueryTable
.Connection = sConn
End With
End Sub
Sub ChangeQT_ThisWorkbookPath()
Dim sPath As String, sDB As String
Dim sConn As String, sSQL As String
sPath = ThisWorkbook.Path
sDB = ThisWorkbook.Name
'ODBC;DSN=Excel Files;
'DBQ=C:\Users\Skip\Documents\2016PharmacyAnalysis.xlsx;
'DefaultDir=C:\Users\Skip\Documents;
'DriverId=1046;MaxBufferSize=2048;PageTimeout=5;
sConn = sConn & "ODBC;DSN=Excel Files;"
sConn = sConn & "DBQ=" & [color #204A87]sPath[/color] & "\" & [color #204A87]sDB[/color] & ";"
sConn = sConn & "DefaultDir=" & [color #204A87]sPath[/color] & ";"
sConn = sConn & "DriverId=1046;MaxBufferSize=2048;PageTimeout=5;"
'''SELECT
''' `'2017$'`.Month
''', `'2017$'`.`2017`
''', `'2017$'`.`2016`
''', `'2017$'`.`2017 Cum`
''', `'2017$'`.`2016 Cum`
'''
'''FROM `C:\Users\Skip\Documents\2016PharmacyAnalysis.xlsx`.`'2017$'` `'2017$'`
sSQL = sSQL & "SELECT"
sSQL = sSQL & " `'2017$'`.Month"
sSQL = sSQL & ", `'2017$'`.`2017`"
sSQL = sSQL & ", `'2017$'`.`2016`"
sSQL = sSQL & ", `'2017$'`.`2017 Cum`"
sSQL = sSQL & ", `'2017$'`.`2016 Cum`"
sSQL = sSQL & vbLf
sSQL = sSQL & "FROM `" & [color #204A87]sPath[/color] & "\" & [color #204A87]sDB[/color] & "`.`'2017$'` `'2017$'`"
With ActiveSheet.ListObjects(1).QueryTable
.Connection = sConn
.Sql = sSQL
.Refresh False
End With
End Sub