?
Solved

Select specific rows within Excel

Posted on 2010-01-10
3
Medium Priority
?
770 Views
Last Modified: 2013-11-26
I have the following select

MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)

How would I configure the select statement to start on a specific row (say row 14) and go until the there were no more rows with data?

0
Comment
Question by:Jedidia
[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
3 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 26279046
You can do that like this....

    MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$14:65536]", MyConnection)

Wayne
0
 

Author Comment

by:Jedidia
ID: 26284503
Hi Webtubbs - This works great for starting at row 14, but is there also a way to identify the last row with data and the select stops at that row?

I am passing this to a datatable and it adds ALOT of empty rows in my datatable..:)
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 1000 total points
ID: 26287388
You can inform the DataAdapter to not include blank rows by using a WHERE clause....

    MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$14:65536] WHERE F1 <> ''", MyConnection)

...where F1 is the first column. The second column would be F2, the third F3, etc.

Wayne
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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
Course of the Month11 days, 3 hours left to enroll

770 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