Problem With SubTotal In Determining Number of Visible Rows of A Filtered Worksheet (Exclude headers?)

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,664
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have this line of code that I am trying to use to get the count of filtered rows on my worksheet.

Code:
f_rowcnt = [subtotal(103,A:A)]

It works, however, the value of f_rowcnt seems to be including the two header rows (rows 1-2) in it's value. This is inaccurate when there are no filtered rows being displayed.

I tried this where lstrow = the value of the last row of data in the worksheet.
Code:
f_rowcnt = [subtotal(103,A3:A &lstrow)]
as well as this variation
Code:
f_rowcnt = [subtotal(103,"A3:A" &lstrow)]

Each resulting in a type mismatch error.

Looking for some assistance to correct this to ensure the correct value for f_rowcnt is calculated.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
How about:
VBA Code:
f_rowcnt = [subtotal(103,A:A)] - 2
 
Upvote 0

Forum statistics

Threads
1,226,530
Messages
6,191,592
Members
453,666
Latest member
madelineharris

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