How many rows have I selected ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Any function that could tell me how many rows have I selected?
i.e. I have selected cells(A1:E5), the function could show me 5 row.

Thanks
 
Hi Paul,

Assiming you are referring to VBA, try:

Dim NumOfRows As Long

NumOfRows = Selection.Rows.Count
 
Hi, Norman,

Thanks for you help. But I need is function, not VBA. Is it any?

Regards
Paul
 
There is no worksheet function for this. Take Norman's suggestion and
write it as a VBA User Defined Function

Function rowsSelected()
Application.Volatile
rowsSelected = Selection.Rows.Count
End Function

Declaring the the function to be volatile is necessary to get it to
recalculate in future recalculation events.

Jerry
 
No, you can count the rows in a specified range, but not the selection.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks everybody!

Jerry W. Lewis said:
There is no worksheet function for this. Take Norman's suggestion and
write it as a VBA User Defined Function

Function rowsSelected()
Application.Volatile
rowsSelected = Selection.Rows.Count
End Function

Declaring the the function to be volatile is necessary to get it to
recalculate in future recalculation events.

Jerry
 
You also have to force a recalc after selecting a range, the selection
itself won't do it.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top