counting the rows returned from an SQL Select

RobAbricon

New Member
Joined
Feb 27, 2007
Messages
25
I would like to generate an excel report whose length will vary depending on the amount of data rows that I pull back from an SQL Select statement. I would like to limit the number of SQL statements I issue, so would prefer not to send a second query using the count(*) function. Does excel know which row was the last populated after the data has been received? Or is there a more elegant way of doing this?

Any help appreciated

Rob
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi, RobAbricon
Welcome to the Board !!!!!

to find the last row on a sheet, you can use
Code:
LastRow = Cells.Find("*", [A1], xlFormulas, xlPart, xlByRows, xlPrevious, False, False).Row


kind regards,
Erik
 
Upvote 0
You star! Works like a dream, didn't even have time to wait for the kettle to boil before your reply came in!
 
Upvote 0
you're WELCOME !!

enjoy the board :-D
a search (see link top of page) for "lastrow" will return plenty of other examples
 
Upvote 0

Forum statistics

Threads
1,223,362
Messages
6,171,642
Members
452,415
Latest member
mansoorali

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top