Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default finding the last row populated in an excel object

I have a VB application that I am using to create a series of excel reports. I am using excel's copy from recordset to transfer an adodb.recordset to my excel object starting in cell A4. The problem I need to resolve is I need to find the highest row populated in the excel object. For whatever reason I am unable to access the adodb.recordset's .recordcount
property. I need to add text at the bottom of the excel so I want to be able to see that the highest populated row is 255 now I can assign a text value to cell A256. How do I identify the maximum row populated in column a considering that data in column A will not begin untill cell A4. Any help will be greatly appreciated. Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default finding the last row populated in an excel object

eli,

range("a65536").End(xlUp).Row
Will give you the row number of the very last row with data in column "A".

range("a4").End(xlDown).Row
Will give you the last row that's not blank starting at "A4"

Just add 1 to either of the above.

John

"eli silverman" wrote in message
...
I have a VB application that I am using to create a series of excel

reports. I am using excel's copy from recordset to transfer an
adodb.recordset to my excel object starting in cell A4. The problem I need
to resolve is I need to find the highest row populated in the excel object.
For whatever reason I am unable to access the adodb.recordset's .recordcount
property. I need to add text at the bottom of the excel so I want to be

able to see that the highest populated row is 255 now I can assign a text
value to cell A256. How do I identify the maximum row populated in column a
considering that data in column A will not begin untill cell A4. Any help
will be greatly appreciated. Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default finding the last row populated in an excel object

John,

It's my mission to remove code such as Range("A65536")<VBG

It should be (IMO)

Range("A"&Rows.Count)

it may vary one day, it certainly hasn't always been 65536.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
eli,

range("a65536").End(xlUp).Row
Will give you the row number of the very last row with data in column "A".

range("a4").End(xlDown).Row
Will give you the last row that's not blank starting at "A4"

Just add 1 to either of the above.

John

"eli silverman" wrote in message
...
I have a VB application that I am using to create a series of excel

reports. I am using excel's copy from recordset to transfer an
adodb.recordset to my excel object starting in cell A4. The problem I need
to resolve is I need to find the highest row populated in the excel

object.
For whatever reason I am unable to access the adodb.recordset's

..recordcount
property. I need to add text at the bottom of the excel so I want to be

able to see that the highest populated row is 255 now I can assign a text
value to cell A256. How do I identify the maximum row populated in column

a
considering that data in column A will not begin untill cell A4. Any help
will be greatly appreciated. Thanks in advance.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default finding the last row populated in an excel object

Bob,

It's my mission to remove code such as Range("A65536")

One convert at a time????
Okay, it makes sense, so you've got my vote.
Now all I have to do is remember to use it.
It's difficult to break old habits, but I'll try.

John

"Bob Phillips" wrote in message
...
John,

It's my mission to remove code such as Range("A65536")<VBG

It should be (IMO)

Range("A"&Rows.Count)

it may vary one day, it certainly hasn't always been 65536.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
eli,

range("a65536").End(xlUp).Row
Will give you the row number of the very last row with data in column

"A".

range("a4").End(xlDown).Row
Will give you the last row that's not blank starting at "A4"

Just add 1 to either of the above.

John

"eli silverman" wrote in message
...
I have a VB application that I am using to create a series of excel

reports. I am using excel's copy from recordset to transfer an
adodb.recordset to my excel object starting in cell A4. The problem I

need
to resolve is I need to find the highest row populated in the excel

object.
For whatever reason I am unable to access the adodb.recordset's

.recordcount
property. I need to add text at the bottom of the excel so I want to

be
able to see that the highest populated row is 255 now I can assign a

text
value to cell A256. How do I identify the maximum row populated in

column
a
considering that data in column A will not begin untill cell A4. Any

help
will be greatly appreciated. Thanks in advance.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default finding the last row populated in an excel object

Good man. 1 down, 5,732 to go (or is that 65535?).

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
Bob,

It's my mission to remove code such as Range("A65536")

One convert at a time????
Okay, it makes sense, so you've got my vote.
Now all I have to do is remember to use it.
It's difficult to break old habits, but I'll try.

John

"Bob Phillips" wrote in message
...
John,

It's my mission to remove code such as Range("A65536")<VBG

It should be (IMO)

Range("A"&Rows.Count)

it may vary one day, it certainly hasn't always been 65536.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
eli,

range("a65536").End(xlUp).Row
Will give you the row number of the very last row with data in column

"A".

range("a4").End(xlDown).Row
Will give you the last row that's not blank starting at "A4"

Just add 1 to either of the above.

John

"eli silverman" wrote in message
...
I have a VB application that I am using to create a series of excel
reports. I am using excel's copy from recordset to transfer an
adodb.recordset to my excel object starting in cell A4. The problem I

need
to resolve is I need to find the highest row populated in the excel

object.
For whatever reason I am unable to access the adodb.recordset's

.recordcount
property. I need to add text at the bottom of the excel so I want to

be
able to see that the highest populated row is 255 now I can assign a

text
value to cell A256. How do I identify the maximum row populated in

column
a
considering that data in column A will not begin untill cell A4. Any

help
will be greatly appreciated. Thanks in advance.










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default finding the last row populated in an excel object

Eli -

You may be able to access the ADO recordset recordcount by
using the client as the cursor location. Before opening
your existing recordset, insert the following:

rst.CursorLocation = adUseClient
rst.Open ...

This method may be slower than using the default server-
side cursor but should allow access to the recordcount.

I would suggest using both client-side cursor recordcount
and Range("A4").End(xlDown).Row (or the method supplied by
Bob Phillips) to ensure that all the rows were copied from
the recordset.

Eric Scott

-----Original Message-----
Good man. 1 down, 5,732 to go (or is that 65535?).

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
Bob,

It's my mission to remove code such as Range("A65536")

One convert at a time????
Okay, it makes sense, so you've got my vote.
Now all I have to do is remember to use it.
It's difficult to break old habits, but I'll try.

John

"Bob Phillips"

wrote in message
...
John,

It's my mission to remove code such as Range("A65536")

<VBG

It should be (IMO)

Range("A"&Rows.Count)

it may vary one day, it certainly hasn't always been

65536.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"John Wilson" wrote in message
...
eli,

range("a65536").End(xlUp).Row
Will give you the row number of the very last row

with data in column
"A".

range("a4").End(xlDown).Row
Will give you the last row that's not blank

starting at "A4"

Just add 1 to either of the above.

John

"eli silverman" wrote in

message
news:1BD06AB7-67BF-4A0A-8FBA-

...
I have a VB application that I am using to create

a series of excel
reports. I am using excel's copy from recordset to

transfer an
adodb.recordset to my excel object starting in cell

A4. The problem I
need
to resolve is I need to find the highest row

populated in the excel
object.
For whatever reason I am unable to access the

adodb.recordset's
.recordcount
property. I need to add text at the bottom of the

excel so I want to
be
able to see that the highest populated row is 255

now I can assign a
text
value to cell A256. How do I identify the maximum

row populated in
column
a
considering that data in column A will not begin

untill cell A4. Any
help
will be greatly appreciated. Thanks in advance.








.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default finding the last row populated in an excel object

The ability to use the RecordCount property is dependent on the cursor
type and the provider.

--

"Eric Scott" wrote in message ...
Eli -

You may be able to access the ADO recordset recordcount by
using the client as the cursor location. Before opening
your existing recordset, insert the following:

rst.CursorLocation = adUseClient
rst.Open ...

This method may be slower than using the default server-
side cursor but should allow access to the recordcount.

I would suggest using both client-side cursor recordcount
and Range("A4").End(xlDown).Row (or the method supplied by
Bob Phillips) to ensure that all the rows were copied from
the recordset.

Eric Scott

-----Original Message-----
Good man. 1 down, 5,732 to go (or is that 65535?).

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
Bob,

It's my mission to remove code such as Range("A65536")
One convert at a time????
Okay, it makes sense, so you've got my vote.
Now all I have to do is remember to use it.
It's difficult to break old habits, but I'll try.

John

"Bob Phillips"

wrote in message
...
John,

It's my mission to remove code such as Range("A65536")

<VBG

It should be (IMO)

Range("A"&Rows.Count)

it may vary one day, it certainly hasn't always been

65536.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"John Wilson" wrote in message
...
eli,

range("a65536").End(xlUp).Row
Will give you the row number of the very last row

with data in column
"A".

range("a4").End(xlDown).Row
Will give you the last row that's not blank

starting at "A4"

Just add 1 to either of the above.

John

"eli silverman" wrote in

message
news:1BD06AB7-67BF-4A0A-8FBA-

...
I have a VB application that I am using to create

a series of excel
reports. I am using excel's copy from recordset to

transfer an
adodb.recordset to my excel object starting in cell

A4. The problem I
need
to resolve is I need to find the highest row

populated in the excel
object.
For whatever reason I am unable to access the

adodb.recordset's
.recordcount
property. I need to add text at the bottom of the

excel so I want to
be
able to see that the highest populated row is 255

now I can assign a
text
value to cell A256. How do I identify the maximum

row populated in
column
a
considering that data in column A will not begin

untill cell A4. Any
help
will be greatly appreciated. Thanks in advance.








.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
First populated cell in row array/ Last populated cell in row arra Skyscan Excel Worksheet Functions 7 May 29th 08 05:20 PM
How do I hide a row in excel if a certain other cell is populated Teresa Hoffman Excel Worksheet Functions 1 October 4th 06 08:50 PM
Finding the cell in which an object lies F*SH Charts and Charting in Excel 2 July 19th 06 09:33 AM
[Click the star to watch this topic] finding 1st populated cell on a vector with va name Excel Discussion (Misc queries) 2 July 19th 06 12:10 AM
finding 1st populated cell on a vector with varying starting points nickname Excel Discussion (Misc queries) 0 July 18th 06 02:15 AM


All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"