View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.newusers
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default detecting range of spreadsheet

Here is some code to give the limits of UsedRange:

Set r = ActiveSheet.UsedRange

nLastRow = r.Rows.Count + r.Row - 1
MsgBox ("last row " & nLastRow)

nLastColumn = r.Columns.Count + r.Column - 1
MsgBox ("last column " & nLastColumn)

nFirstRow = r.Row
MsgBox ("first row " & nFirstRow)

nFirstColumn = r.Column
MsgBox ("first column " & nFirstColumn)

numrow = r.Rows.Count
MsgBox ("number of rows " & numrow)

numcol = r.Columns.Count
MsgBox ("number of columns " & numcol)

--
Gary''s Student - gsnu2007d


"altein" wrote:


Hi,

I'm trying to design a simple spreadsheet that does some accounting
calculation and then represents them in a variety of charts. I'm
simply using macros through demonstration rather than coding. I was
wondering how one might be able to use VBA to detect the bottom right
most range Y coordinate(X letter is predertimed - number of fields in
spreadsheet) so the macro will run correctly regardless of how many
rows there are?

Thanks ahead,
Altein




--
altein