View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Fritz Hilgemann Fritz Hilgemann is offline
external usenet poster
 
Posts: 8
Default Determine sheet dimensions

Hi Roger,

unfortunately, this method only returns the last entry of a single row or
column. To find out the full dimension, I would have to test 65535 rows plus
256 cols (which indeed is less than 65535 * 256 cells, but still requires
lots of CPU).

Regards
Fritz

"Roger Govier" wrote in message
...
Hi Fritz

Maybe this will help you

Sub FindLastCell()
Dim lastrow As Long, lastcolumn As Long, lastcell As Variant, Myarea As
Variant
lastrow = Cells(Rows.Count, 1).End(xlUp).row
MsgBox "Last ROW Number is " & lastrow, , ""
lastcolumn = Cells(1, Columns.Count).End(xlToLeft).Column
MsgBox "Last COLUMN Number is " & lastcolumn, , ""
lastcell = Cells(lastrow, lastcolumn).Address
MsgBox "Last Cell Address is " & lastcell, , ""
Myarea = ActiveSheet.UsedRange.Address
MsgBox "Used Range is " & Myarea, , ""
End Sub
--
Regards

Roger Govier


"Fritz Hilgemann" wrote in message
...
Hello NG,
I rarely use Excel programming which doesn't mak me an expert. So I hope
to find an answer on this:
From a single sheet, I want to determine it's used dimension, that the
last non-empty row (over all columns) and the last non-empty column (over
all rows). The sheet, though, may have empty cells, rows or columns in
between. I do not want to iterate and test 16 Mio. cells separately, I am
hoping on a method or attribute I have overlooked or a tricky algorithm.
Regards
Fritz