Hi,
I hv created a From Date & To Date in excel (Sheet1). Under cell A3, I hv From Date :: 01-01-2010 and cell A4 To Date :: 31-08-2010.
How do I link the Date Range to the below macro:-
Sub Sales()
Dim StrSQl As String
Con = "Provider=IBMDA400;Data Source=XXX.XXX.XXX.XXX;User Id=yyyy;Password=zzzz"
Set Db = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.recordset")
Db.connectionSTring = Con
Db.Open
StrSQl = "select myuc, sum (myac) as Amount from myabc.myqwerty where mydt >= 20100101 and mydt <= 20100831 group by (mycl)"
rs.Open StrSQl, Db, 3, 3
Sheet1.Cells(10, 1).CopyFromRecordset rs
rs.Close
Set rs = Nothing
Set cn = Nothing
End Sub
Pls take note of the date format between excel & SQL statement. Both are different in formats.
Thanks.