hi guys
complete newbie to this - looking to create a pivot table from an mysql db hosted remotely, i have everything working at the moment but i would like to expand on it so that a user can enter a date on the excel sheet and click refresh and the query will use the date range from that cell
eg select * from table1 where date = C1
this is very sloppy but i've got this far
Sub SetStartDate()
Dim rStartDate As Range
Set rStartDate = Range("D1")
End Sub
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+Shift+M
'
With ActiveWorkbook.Connections("sales_weekly").ODBCConnection
.BackgroundQuery = True
.CommandText = Array( _
"SELECT * FROM `db`.`table1` WHERE `Month` = ") rStartDate
.CommandType = xlCmdSql
.Connection = "ODBC;DSN=Database;"
.RefreshOnFileOpen = False
.SavePassword = False
.SourceConnectionFile = ""
.ServerCredentialsMethod = xlCredentialsMethodIntegrated
.AlwaysUseConnectionFile = False
End With
With ActiveWorkbook.Connections("table1")
.Name = "table1"
.Description = "Last Week"
End With
End Sub
any help with this would be greatly appreciated!!! thanks
Bookmarks