kosenrufu
asked on
What is the Excel VBA to count number of rows in a filtered range?
What is the Excel VBA to count number of rows in a filtered range?
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How about for a range in question of D5 thru D1400:
msgbox WorksheetFunction.Subtotal (3, Range("d5:d1400"))
Of course, you could always use the Subtotal worksheet function right in the worksheet. You don't really need VBA. The Subtotal function can also give you average, min, max, count, counta, sum of the visible rows in a filtered range.
msgbox WorksheetFunction.Subtotal
Of course, you could always use the Subtotal worksheet function right in the worksheet. You don't really need VBA. The Subtotal function can also give you average, min, max, count, counta, sum of the visible rows in a filtered range.
"When you have selected a range, it is sometimes useful to know how many rows or columns you have selected as this information can be used in your macros (for eg when you have reached the end, you will know it is time to stop the macros":
Sub Count()
myCount = Selection.Rows.Count 'Change Rows to Columns to count columns
MsgBox myCount
End Sub
http://www.angelfire.com/biz7/julian_s/julian/julians_macros.htm