Link to home
Start Free TrialLog in
Avatar of mustish1
mustish1

asked on

Skip First Row

Hi: Can any one please tell me how to i skip first record in the do while loop as the first row in the excel sheet is the headings

Thanks.

Private Sub readExcelFile()
Dim objConn As ADODB.Connection
Dim objRec As ADODB.Recordset
Dim strFileName As String
Dim strSheet As String
Dim arrData As Variant
strFileName = "C:\REMITandNSF\remit.xls" 'name of the Excel file
strSheet = "Sheet1"   'name of worksheet within the Excel file
Set objConn = New ADODB.Connection
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strFileName & ";Extended Properties=""Excel 8.0;"""
Set objRec = New ADODB.Recordset
strtest = "SELECT * FROM [" & strSheet & "$]"
Debug.Print strtest
objRec.Open "SELECT * FROM [" & strSheet & "$]", objConn, adOpenKeyset, adLockReadOnly
Do While Not objRec.EOF
    MsgBox objRec.Fields(0).Value
    MsgBox objRec.Fields(1).Value
    objRec.MoveNext
Loop
objConn.Close
Set objRec = Nothing
Set objConn = Nothing
End Sub
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Happy to help again! :^)