Getting the count from autofilter

  • Thread starter Thread starter Jason V
  • Start date Start date
J

Jason V

I recorded a macro to use autofilter. I do not know how to access the count
of the result after filtering on a column. Let's say I have 10 rows and after
I filter only 2 rows show up. I want to access the result that gives me 2. I
think this is count but wha tis the code to get it.

Thanks
 
Hi Jason

Something like this after the code that do the filter

With ActiveSheet.AutoFilter.Range.Columns(1)
On Error Resume Next
Set rng = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then MsgBox rng.Cells.Count - 1
End With
 
Thank you. Exactly what I wanted.
--
Jason V


Ron de Bruin said:
Hi Jason

Something like this after the code that do the filter

With ActiveSheet.AutoFilter.Range.Columns(1)
On Error Resume Next
Set rng = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then MsgBox rng.Cells.Count - 1
End With
 

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