You'll need to set a reference to Microsoft ActiveX Data Objects 2.1 Library for this to run
Hope it will help
Private Sub CommandButton1_Click()
Dim objCon As ADODB.Connection
Dim rsSample As ADODB.Recordset
Dim strSQL As String
Dim intCol As Integer
Dim lngRow As Long
Dim strtDate As Date
Dim endDate As Date
strtDate = CDate(UserForm1.TextBox1.Text)
endDate = CDate(UserForm1.TextBox2.Text)
Set objCon = CreateObject("ADODB.Connection"

Set rsSample = New ADODB.Recordset
strSQL = "Select * From Sample_Table where Date_Created between #" & strtDate & "# and #" & endDate & "#"
objCon.Open "DSN_Name"
rsSample.Open strSQL, objCon, 3, 3
lngRow = 1
Do While Not rsSample.EOF
For intCol = 0 To rsSample.Fields.Count - 1
Sheets("Sheet1"

.Cells(lngRow, intCol + 1).Value = rsSample.Fields(intCol).Value
Next intCol
lngRow = lngRow + 1
rsSample.MoveNext
Loop
End Sub