Here is my simple SQL query in Excel 2003
Sub Date_Range()
Dim Start_date As String, strH As String
Start_date = Application.InputBox(Prompt:="Start date?", Type:=2)
strH = "Select MATTER_NO, DETAIL1, DATE_OPENED" _
& " From Matter Where DATE_OPENED >= 'Start_date' " _
& " Group by MATTER_NO, DETAIL1, DATE_OPENED Order by DATE_OPENED ASC"
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Worksheets("Sheet5").Range("A2"), Sql:=strH)
.Refresh
End With
'
End Sub
Can someone tell me how to overcome this error when I am writing sql queries with VB in Excel.
Thanks
Sub Date_Range()
Dim Start_date As String, strH As String
Start_date = Application.InputBox(Prompt:="Start date?", Type:=2)
strH = "Select MATTER_NO, DETAIL1, DATE_OPENED" _
& " From Matter Where DATE_OPENED >= 'Start_date' " _
& " Group by MATTER_NO, DETAIL1, DATE_OPENED Order by DATE_OPENED ASC"
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Worksheets("Sheet5").Range("A2"), Sql:=strH)
.Refresh
End With
'
End Sub
Can someone tell me how to overcome this error when I am writing sql queries with VB in Excel.
Thanks
Last edited: