ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   detecting range of spreadsheet (https://www.excelbanter.com/new-users-excel/177614-detecting-range-spreadsheet.html)

altein

detecting range of spreadsheet
 

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

Gary''s Student

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



All times are GMT +1. The time now is 05:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com