Hi
Skip on this website helped me with getting formulae to work but I'm not sure what he did and I need to replicate for another worksheet in the same Excel document (I'm using Excel 2002).
I've used VBA for Access but not Excel so if someone could please explain what each of the steps is doing then that would help:
Option Explicit
Private Sub Worksheet_Activate()
Dim sConn As String, sSQL As String, sPath As String, sDB As String
sPath = ThisWorkbook.Path
sDB = Split(ThisWorkbook.Name, ".")(0)
sConn = "ODBC;DSN=Excel Files;"
sConn = sConn & "DBQ=" & sPath & "\" & sDB & ".xls;"
sConn = sConn & "DefaultDir=" & sPath & ";"
sConn = sConn & "DriverId=790;MaxBufferSize=2048;PageTimeout=5;"
With ActiveSheet
With .QueryTables(1)
.Connection = sConn
Debug.Print .CommandText
.Refresh False
End With
.Calculate
End With
End Sub
In the intermediate window is the code:
WHERE (trim(`'09_10$'`.F5) Is Not Null)
SELECT `'09_10$'`.F5 AS 'referral', `'09_10$'`.F6 AS 'assessment'
FROM `'09_10$'` `'09_10$'`
WHERE (trim(`'09_10$'`.F5) Is Not Null)
9_10$'`
Where is this is the original code i.e. I wish to change but it won't change.
Thanks for any and all assistance.
Shelby
Skip on this website helped me with getting formulae to work but I'm not sure what he did and I need to replicate for another worksheet in the same Excel document (I'm using Excel 2002).
I've used VBA for Access but not Excel so if someone could please explain what each of the steps is doing then that would help:
Option Explicit
Private Sub Worksheet_Activate()
Dim sConn As String, sSQL As String, sPath As String, sDB As String
sPath = ThisWorkbook.Path
sDB = Split(ThisWorkbook.Name, ".")(0)
sConn = "ODBC;DSN=Excel Files;"
sConn = sConn & "DBQ=" & sPath & "\" & sDB & ".xls;"
sConn = sConn & "DefaultDir=" & sPath & ";"
sConn = sConn & "DriverId=790;MaxBufferSize=2048;PageTimeout=5;"
With ActiveSheet
With .QueryTables(1)
.Connection = sConn
Debug.Print .CommandText
.Refresh False
End With
.Calculate
End With
End Sub
In the intermediate window is the code:
WHERE (trim(`'09_10$'`.F5) Is Not Null)
SELECT `'09_10$'`.F5 AS 'referral', `'09_10$'`.F6 AS 'assessment'
FROM `'09_10$'` `'09_10$'`
WHERE (trim(`'09_10$'`.F5) Is Not Null)
9_10$'`
Where is this is the original code i.e. I wish to change but it won't change.
Thanks for any and all assistance.
Shelby