detecting range of spreadsheet

  • Thread starter Thread starter altein
  • Start date Start date
A

altein

Hi,

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

Thanks ahead,
Altei
 
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)
 
Back
Top