title: How to build Excel macro with date range
body: <p>I hv created a From Date &amp; To Date in excel (Sheet1). Under cell A3, I hv From Date :: 01-01-2010 and cell A4 To Date :: 31-08-2010.</p>
  
  <p>How do I link the Date Range to the below macro:-</p>
  
  <pre><code>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 &gt;= 20100101 and mydt &lt;= 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
  </code></pre>
  
  <p>Pls take note of the date format between excel &amp; SQL statement. Both are different in formats.</p>
  
  <p>Thanks. </p>