Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the first row from the excel sheet

Status
Not open for further replies.

juggers

IS-IT--Management
Joined
Jul 11, 2000
Messages
66
Location
SA
Hi,
I am trying to read rows from an excel sheet it is not starting from the first row, so I have to a copy the first row a paste it in the second row so it will start from row 2, how can i make it to start from the first row?


------code
filen = InputBox("Enter the xls file name")

sheetname = InputBox("Enter the Sheet name") & "$"
Set CONN = New ADODB.Connection
Set RS = New ADODB.Recordset
CONN.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & filen & ";" & _
"Extended Properties=""Excel 8.0;HDR=YES"""

With RS
.Open "SELECT * FROM [" & sheetname & "]", CONN, adOpenDynamic, adLockOptimistic
.MoveFirst
End With
Do Until RS.EOF
bla bla
loop
.Movenext


Regards

time is the father of truth
 
I may be wrong but it might be that the select query is expecting there to be a column header so it skips row 1 which would be the header row??

It might be an idea to look at excel automation using a reference to Microsoft Excel x.0 Object Library for easier Excel manipulation.

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
You have


"Extended Properties=""Excel 8.0;HDR=YES"""

Possible HDR=NO should be used?
 
EXACTLY!!!
Thanks mych..good point

Regards

time is the father of truth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top