ReadyToRetire
Programmer
I am trying to read some dates which are located in column A from an excel file into a listbox. Everything works fine except it does not pick up the first row. The date ranges are from August 1,2003 through August 12, 2003. When I debug through the code, the first record is always 08/02/2003 (August 2,2003). I've tried using A1:A12 and A:A in the select statement to no avail. This is currently a test and the dates are going to be changed by the user on a yearly basis.
the following is the code :
**************************
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sconn As String
Dim sfile As String
sfile = "C:\temp\test2.xls"
sconn = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & sfile
rs.Open "SELECT * FROM [sheet1$]", sconn, 2, 2
Ii = 0
While Not rs.EOF
If Not rs.EOF Then
List1.List(Ii) = rs.Fields.Item(0).Value
rs.MoveNext
Ii = Ii + 1
End If
Wend
rs.Close
Set rs = Nothing
***************************************
Any help would be appreciated..... Thanks in advance
the following is the code :
**************************
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sconn As String
Dim sfile As String
sfile = "C:\temp\test2.xls"
sconn = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & sfile
rs.Open "SELECT * FROM [sheet1$]", sconn, 2, 2
Ii = 0
While Not rs.EOF
If Not rs.EOF Then
List1.List(Ii) = rs.Fields.Item(0).Value
rs.MoveNext
Ii = Ii + 1
End If
Wend
rs.Close
Set rs = Nothing
***************************************
Any help would be appreciated..... Thanks in advance