johnsun1976
Programmer
Hi. I have this code to open an Excel worksheet and read it in.. When I try to read in the first column, which is a list of numbers with may have a letter (ie. 4, 4a, 4b, 5,..), the letters are stripped (ie. 4a comes in a 4). Does anyone know what I'm doing wrong?
Thanks
John
Dim cnXL As New ADODB.Connection
Dim rs As New ADODB.Recordset
'open Excel through ADO
Set cnXL = New ADODB.Connection
With cnXL
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = _
"Data Source=" & filepath & ";" & _
"Extended Properties=""Excel 8.0;" & _
"HDR=no);"""
.Open
End With
rs.Open "Select * from [Sheet1$]", cnXL, adOpenStatic
Dim LotNumber As String
With rs
.MoveFirst
While Not .EOF
LotNumber = .Fields("LotNumber"
Wend
End with
Thanks
John
Dim cnXL As New ADODB.Connection
Dim rs As New ADODB.Recordset
'open Excel through ADO
Set cnXL = New ADODB.Connection
With cnXL
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = _
"Data Source=" & filepath & ";" & _
"Extended Properties=""Excel 8.0;" & _
"HDR=no);"""
.Open
End With
rs.Open "Select * from [Sheet1$]", cnXL, adOpenStatic
Dim LotNumber As String
With rs
.MoveFirst
While Not .EOF
LotNumber = .Fields("LotNumber"
Wend
End with