Finding last row

V

Victoria

hi gurus

I have a 'novice' question. It refers to a table that can a variable number
of rows and columns. The cells of the table have lined borders. The upper
left cell of the table is "A3". I need code that produces the row number
of the LAST row in the table. (This row may have values in its cells or its
cells may be empty.)


thanks a lot
 
V

Victoria

hi Jacob - your code snippet works well when there is an entry in the cell.
But the cells may be empty. Every cell in the table has a line border on
all 4 sides (When printed, many cells will be empty, but workers fill in
values for later data entry.) What I need is to be able to identify the row
number of the last formatted row.

Thanks
Victoria
 
V

Victoria

hi again

I'm using Excel 2002. I'm not sure what you mean by a '2007 table', but I'm
simply refering to an area of the Sheet that has bordered cells. If printed,
it would look like a sheet of graph paper. I need to be able to identify the
last row, even if its cells contain no values.

Sorry if I'm using terms improperly
Victoria
 
J

Jacob Skaria

Hi Victoria

Microsoft has introduced a new concept of working with tables of data in
Excel 2007. This new functionality is called "tables" which is the successor
of Excel 2003's "List" feature........

If you are having a list you can try
Activesheet.ListObjects(1).listrows.count

If not a list but only formatted with borders... Then try the below macro
Sub Macro()

Dim lngRow As Long
lngRow = 3
Do: lngRow = lngRow + 1
Loop Until Range("A" & lngRow).Borders.LineStyle = xlLineStyleNone
lngRow = lngRow - 1

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top