vba code to count visible rows after autofiltering a table

epb613

New Member
Joined
Feb 18, 2010
Messages
14
I autofiltered a table. Now I want to count the remaining rows. I searched online and found the following code snippet, but it doesn't work. It should return 500, but it returns 1000 (it's counting cells, not rows). What's wrong? (If I take out the SpecialCells property, it returns 500 like it should, but obviously I need to leave that in.)

Code:
MsgBox Range.Rows.SpecialCells(xlCellTypeVisible).Count

Thanks!
Pinny
 
Hi All

I know that I'm late to this, but I also needed code for this, and found the below to fit my needs and thought I'd share
lVisibleRow = Application.WorksheetFunction.Subtotal(3, ActiveSheet.Range("A:A"))
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top