+ Reply to Thread
Results 1 to 3 of 3

return row count of filtered data.

  1. #1
    Registered User
    Join Date
    03-09-2006
    Posts
    11

    return row count of filtered data.

    I want to be able to count the amount of rows returned after i filter some data. If the row count>1, eg atleast one row returned then i want the script to execute some code

    When i pause my macro, i can see 11 rows are selected, and those 11 rows are copied to the new sheet but the row count returned is too large.

    Please Login or Register  to view this content.
    Count = ActiveSheet.AutoFilter.ROW.Count ' This returns the value empty for some reason
    Last edited by tarns; 03-10-2006 at 03:45 AM.

  2. #2
    Nigel
    Guest

    Re: return row count of filtered data.

    You could use the worksheet subtotal function to count the number of values
    in the filtered list, set the 'myRange' for the total un-filtered range
    first e.g........


    ' the unfiltered list range extent
    Set myRange = Range("A4:A1000")

    ' get the filtered list count
    Count = Application.WorksheetFunction.Subtotal(3, myRange)

    --
    Cheers
    Nigel



    "tarns" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I want to be able to count the amount of rows returned after i filter
    > some data. If the row count>1, eg atleast one row returned then i want
    > the script to execute some code
    >
    > When i pause my macro, i can see 11 rows are selected, and those 11
    > rows are copied to the new sheet but the row count returned is too
    > large.
    >
    >
    > Code:
    > --------------------
    >
    > Sheets("List").Select
    > Selection.AutoFilter Field:=7, Criteria1:=">=" & Range("I1").Value '

    Filter data. (Rows returned are 11)
    > Set NewIssueRC = ActiveSheet.AutoFilter.Range
    > NewIssueRC.Copy 'Copy

    Filtered Data. 11 rows are selected
    > Count = ActiveSheet.AutoFilter.Range.Count ' DOSNT WORK.

    Returns 3441 rows of data.
    >
    > If Count > 0 Then
    > Application.StatusBar = "CREATING NEW ISSUES PIVOT TABLE......."
    > ........
    > ........
    >
    > --------------------
    >
    >
    > --
    > tarns
    > ------------------------------------------------------------------------
    > tarns's Profile:

    http://www.excelforum.com/member.php...o&userid=32291
    > View this thread: http://www.excelforum.com/showthread...hreadid=520955
    >




  3. #3
    Registered User
    Join Date
    03-09-2006
    Posts
    11
    Thanks bro, also got it with

    NewIssueCount = ActiveSheet.AutoFilter.Range.Columns(1).SpecialCells(xlVisible).Count - 1

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1