View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
SUDHENDRA SUDHENDRA is offline
external usenet poster
 
Posts: 21
Default FINDING LAST ROW OF THE DATA

THANKS
-----Original Message-----
Won't always work though.

Open up a new sheet, populate cells D10:F15 and then try

that code. It will
give you 3 for the last column (Should be 6) and 6 for

the last row (Should be
15). It counts the rows/columns *within* the UsedRange

and does not necessarily
give you the last of either.

lcol = ActiveSheet.UsedRange.Column - 1 + _
ActiveSheet.UsedRange.Columns.Count

lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

Take lcol with example ranges I gave you above:-

ActiveSheet.UsedRange.Column will give you the first

column in the range, ie 4
ActiveSheet.UsedRange.Columns.Count will give you the

number of columns in that
range ie 3
Add the first column to the number of columns and you

will always have 1 more
than the last column, hence the -1 in there. Same

principle for rows.

--
Regards
Ken....................... Microsoft MVP -

Excel
Sys Spec - Win XP Pro / XL 00/02/03

---------------------------------------------------------

-------------------
It's easier to beg forgiveness than ask permission :-)
---------------------------------------------------------

-------------------



"pikus " wrote in

message
...
I asked this question not long ago and my personal

favorite answer is:

colCount = ActiveSheet.UsedRange.Columns.Count

It also works with Rows. - Pikus


---
Message posted from http://www.ExcelForum.com/



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system

(http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date:

02/01/2004


.