Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Extracting results of Advanced Filter.

Heya, folks.

When an Advanced Filter is run, the following text appears in the
Excel status bar:

"X of Y records found"

.... where X is the number of records that matched the filter criteria,
and Y is the total number of records in the filtered range.

Is there any way to extract these values programmatically? I may be
blind, but I don't see it anywhere in the relevant documentation.
I've been able to do it by capturing the status bar text and parsing
it to extract the numbers, but I'm hoping there's a more elegant way
to go about it.

Thanks,

- David Prokopetz.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Extracting results of Advanced Filter.

Hi David,

One way:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim iTotal As Long
Dim iFiltered As Long

Set WB = Workbooks("MyBook.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("_FilterDatabase")

iTotal = rng.Rows.Count - 1
iFiltered = rng.Columns(1).SpecialCells(xlVisible).Count - 1

'=============
Public Sub Tester0()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim iTotal As Long
Dim iFiltered As Long

Set WB = ThisWorkbook
Set SH = WB.Sheets("Sheet1")
Set rng = SH.Range("_FilterDatabase")

iTotal = rng.Rows.Count - 1
iFiltered = rng.Columns(1).SpecialCells(xlVisible).Count - 1

MsgBox Prompt:=iFiltered & " rows of " _
& iTotal & " are visible", _
Buttons:=vbInformation, _
Title:="Filter Records"

End Sub
'<<=============


---
Regards,
Norman


wrote in message
oups.com...
Heya, folks.

When an Advanced Filter is run, the following text appears in the
Excel status bar:

"X of Y records found"

... where X is the number of records that matched the filter criteria,
and Y is the total number of records in the filtered range.

Is there any way to extract these values programmatically? I may be
blind, but I don't see it anywhere in the relevant documentation.
I've been able to do it by capturing the status bar text and parsing
it to extract the numbers, but I'm hoping there's a more elegant way
to go about it.

Thanks,

- David Prokopetz.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Extracting results of Advanced Filter.

Hi David,

A bit of a cut & paste problem!

Tryimg again:

One way:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim iTotal As Long
Dim iFiltered As Long

Set WB = Workbooks("Mybook.xls")
Set SH = WB.Sheets("Sheet1")
Set rng = SH.Range("_FilterDatabase")

iTotal = rng.Rows.Count - 1
iFiltered = rng.Columns(1).SpecialCells(xlVisible).Count - 1

MsgBox Prompt:=iFiltered & " rows of " _
& iTotal & " are visible", _
Buttons:=vbInformation, _
Title:="Filter Records"
End Sub
'<<=============


---
Regards,
Norman


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
Advanced Filter - extracting unique records Balan Excel Worksheet Functions 2 September 4th 07 03:12 AM
Why won't advanced filter return filter results? jaws4518 Excel Worksheet Functions 5 September 12th 06 06:11 PM
Results of Advanced Filter to Array Zone Excel Programming 4 August 25th 06 06:41 PM
Advanced Filter/ Extracting Data Lisa Excel Discussion (Misc queries) 2 July 7th 06 03:15 PM
Advanced Filter/Extracting Data jayrthomas Excel Discussion (Misc queries) 3 May 11th 06 01:42 AM


All times are GMT +1. The time now is 11:51 PM.

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

About Us

"It's about Microsoft Excel"