How do I count the number of ENTIRE rows selected on a worksheet? Using Selection.Rows.Count returns 1 if I don't highlight the entire row. I want the result to be 0 if an entire row has not been selected.
How do I count the number of ENTIRE rows selected on a worksheet? Using Selection.Rows.Count returns 1 if I don't highlight the entire row. I want the result to be 0 if an entire row has not been selected.
No doubt a few routes... one might be:
![]()
Please Login or Register to view this content.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Thanks for that, it works great! Although I must admit I'm not sure I understand how it works??
Also
rgds![]()
Please Login or Register to view this content.
johnjohns
Just checks to see if the column count of the range being iterated matches the column count of the sheet itself
(in reality this latter value [sheet] should be calculated only once prior to commencement of loop given it's fixed (varies only by version))
In VBA Boolean True coerced equates to -1 (as opposed to 1 in native XL) and False to 0 hence:
on this basis I used an approach of1 - TRUE --> 2 (1--1)
1 - FALSE --> 1 (1-0)
however you may find johnjohn's approach more logical/preferable, ie![]()
Please Login or Register to view this content.
you should use whichever makes most sense given you need to maintain !![]()
Please Login or Register to view this content.
Thanks both for your help, much appreciated.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks