Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return row number as integer 2

Status
Not open for further replies.

sterlecki

Technical User
Oct 25, 2003
181
US
I would like to return to a variable the row number of the active cell. (say b7)

dim r as integer

r= ActiveCell.address

debug.print r (returns $b$7) I only want the row number

What is the proper syntax?

Just learning VBA in Excel

Thanks
 
And this ?
r = ActiveCell.Row

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 


FYI,

Always Define a Row Number variable as LONG instead of INTEGER, since there are 65536 rows in an Excel sheet which exceeds the size of an INTEGER variable.

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Thanks to you both PHV and SkipVought. Why is it always simpler than I thought?
 
Just as a sidebar, if you are ever setting a variable for the absolute location of a point in a Word document, always declare it as Long, not Integer - for the same reason Skip mentions. The position number jumps to larger than an integer WAAAAY faster than one would think.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top