+ Reply to Thread
Results 1 to 3 of 3

Thread: Clearing autofilters and sorting on a non active sheet

  1. #1
    Registered User
    Join Date
    10-04-2011
    Location
    Morecambe, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Clearing autofilters and sorting on a non active sheet

    Afternoon,

    I have a table similar to this in a spreadsheet (it has a lot more locations and departments and the numbers are different but you get the gist)..

    Loc1 Loc2 Loc3
    Department 1 5 0 5
    Department 2 6 156 66
    Department 3 25 0 52
    Department 4 0 0 1


    I've created some dynamic ranges which chart the information based on user inputs but now I am getting the problem of pie charts leaving in zero values. Basically, I now want to be able to write three macros which filter the table (for each loc) to exclude any zero values. By recording some macros I have managed to do this when I have the sheet selected as the active sheet but as this is going to be for a dashboard I want it all to update automatically from the main page.

    What I currently have is...

      Range("I65:K65").Select
        ActiveSheet.ShowAllData
        Range("I65").Select
        ActiveSheet.Range("$D$65:$M$83").AutoFilter Field:=6, Criteria1:="<>0", _
            Operator:=xlAnd
    I am new to using macros, how do I change this so that it doesn't need to be on the active sheet?

    Thanks,

    Alice
    Last edited by qaliq; 02-13-2012 at 10:11 AM. Reason: solved

  2. #2
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: Clearing autofilters and sorting on a non active sheet

    with sheets("Sheet name")
    .ShowAllData
        .Range("$D$65:$M$83").AutoFilter Field:=6, Criteria1:="<>0", _
            Operator:=xlAnd
    End With
    Good luck.

  3. #3
    Registered User
    Join Date
    10-04-2011
    Location
    Morecambe, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Clearing autofilters and sorting on a non active sheet

    Perfect!

    Thank you for your super quick reply

+ 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.2.0