Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Skip First Row

Posted on 2007-04-04
2
Medium Priority
?
378 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:mustish1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 18850250
objRec.MoveFirst
objRec.MoveNext 'skips the first line
Do While Not objRec.EOF
    MsgBox objRec.Fields(0).Value
    MsgBox objRec.Fields(1).Value
    objRec.MoveNext
Loop
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18850338
Happy to help again! :^)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question