Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default number of rows returned by autofilter?

Hello.

Is there a quick way to retrieve the number of rows returned in an
AutoFilter object?

For instance, if there were 20 rows of data, but when the autofilter
criteria are applied, only 5 rows are visible... to return that number, 5, in
code?

Thanks,
Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default number of rows returned by autofilter?

Option Explicit
Sub testme()

Dim rngF As Range

With ActiveSheet.AutoFilter.Range
Set rngF = .Columns(1).Cells.SpecialCells(xlCellTypeVisible)
If rngF.Cells.Count = 1 Then
'only the header is visible
MsgBox "no details shown"
Else
MsgBox rngF.Cells.Count - 1 & " rows of data visible"
End If
End With
End Sub

mark wrote:

Hello.

Is there a quick way to retrieve the number of rows returned in an
AutoFilter object?

For instance, if there were 20 rows of data, but when the autofilter
criteria are applied, only 5 rows are visible... to return that number, 5, in
code?

Thanks,
Mark


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default number of rows returned by autofilter?

Thanks, Dave.

Exactly what I need.

"Dave Peterson" wrote:

Option Explicit
Sub testme()


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default number of rows returned by autofilter?

Assuming that column A is part of the data

Dim x As Long, y As Long

x = Cells(Rows.Count, "A").End(xlUp).Row

y = Range(Cells(1, 1), Cells(x, 1)).SpecialCells(xlCellTypeVisible).Count
MsgBox y


--
steveB

Remove "AYN" from email to respond
"mark" wrote in message
...
Hello.

Is there a quick way to retrieve the number of rows returned in an
AutoFilter object?

For instance, if there were 20 rows of data, but when the autofilter
criteria are applied, only 5 rows are visible... to return that number, 5,
in
code?

Thanks,
Mark



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default number of rows returned by autofilter?

Yep, that would work too. Thanks. It was the
..SpecialCells(xlCellTypeVisible) that I needed to learn about.

Thanks

"STEVE BELL" wrote:

Assuming that column A is part of the data

Dim x As Long, y As Long

x = Cells(Rows.Count, "A").End(xlUp).Row

y = Range(Cells(1, 1), Cells(x, 1)).SpecialCells(xlCellTypeVisible).Count
MsgBox y


--
steveB

Remove "AYN" from email to respond
"mark" wrote in message
...
Hello.

Is there a quick way to retrieve the number of rows returned in an
AutoFilter object?

For instance, if there were 20 rows of data, but when the autofilter
criteria are applied, only 5 rows are visible... to return that number, 5,
in
code?

Thanks,
Mark






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default number of rows returned by autofilter?

Mark,

Glad to help...

Picked that up from this ng.
Also got it by recording a Edit Goto Special visible cells

--
steveB

Remove "AYN" from email to respond
"mark" wrote in message
...
Yep, that would work too. Thanks. It was the
.SpecialCells(xlCellTypeVisible) that I needed to learn about.

Thanks

"STEVE BELL" wrote:

Assuming that column A is part of the data

Dim x As Long, y As Long

x = Cells(Rows.Count, "A").End(xlUp).Row

y = Range(Cells(1, 1), Cells(x, 1)).SpecialCells(xlCellTypeVisible).Count
MsgBox y


--
steveB

Remove "AYN" from email to respond
"mark" wrote in message
...
Hello.

Is there a quick way to retrieve the number of rows returned in an
AutoFilter object?

For instance, if there were 20 rows of data, but when the autofilter
criteria are applied, only 5 rows are visible... to return that number,
5,
in
code?

Thanks,
Mark






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default number of rows returned by autofilter?

Also got it by recording a Edit Goto Special visible cells

Ahh, now that you mention it, I do remember exploring that menu item once...

But I wasn't thinking of that just now.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default number of rows returned by autofilter?

Some people put notes/other data after the autofilter range. If that's the
case, then this may give you incorrect results.



STEVE BELL wrote:

Assuming that column A is part of the data

Dim x As Long, y As Long

x = Cells(Rows.Count, "A").End(xlUp).Row

y = Range(Cells(1, 1), Cells(x, 1)).SpecialCells(xlCellTypeVisible).Count
MsgBox y

--
steveB

Remove "AYN" from email to respond
"mark" wrote in message
...
Hello.

Is there a quick way to retrieve the number of rows returned in an
AutoFilter object?

For instance, if there were 20 rows of data, but when the autofilter
criteria are applied, only 5 rows are visible... to return that number, 5,
in
code?

Thanks,
Mark


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default number of rows returned by autofilter?

Noted!

Thanks...

--
steveB

Remove "AYN" from email to respond
"Dave Peterson" wrote in message
...
Some people put notes/other data after the autofilter range. If that's
the
case, then this may give you incorrect results.



STEVE BELL wrote:

Assuming that column A is part of the data

Dim x As Long, y As Long

x = Cells(Rows.Count, "A").End(xlUp).Row

y = Range(Cells(1, 1), Cells(x, 1)).SpecialCells(xlCellTypeVisible).Count
MsgBox y

--
steveB

Remove "AYN" from email to respond
"mark" wrote in message
...
Hello.

Is there a quick way to retrieve the number of rows returned in an
AutoFilter object?

For instance, if there were 20 rows of data, but when the autofilter
criteria are applied, only 5 rows are visible... to return that number,
5,
in
code?

Thanks,
Mark


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find the number of rows returned in a filter Tony W Excel Discussion (Misc queries) 5 May 30th 05 10:36 PM
How do I get the number of rows that meet an autofilter criterion. hako Excel Worksheet Functions 4 November 19th 04 04:09 PM
Advanced filter - counting the number of rows returned? Lawrence Coomber Excel Programming 1 August 11th 04 09:32 AM
Changing data returned from an autofilter ChrisBat Excel Programming 1 January 5th 04 08:39 PM
Finding row count and filtered rows returned by Autofilter Joseph Uher Excel Programming 0 September 20th 03 08:49 PM


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"