Results 1 to 5 of 5

Auto filter based on true / false criteria

Threaded View

  1. #1
    Registered User
    Join Date
    08-11-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    Auto filter based on true / false criteria

    Hi,

    I am trying to write a macro which applies an auto filter to a table, but to apply the filter based on a selection of true / false criteria. This is what I have so far..when I run, it doesn't work with the if statement but the second line does work on its own. Any ideas what I'm doing wrong.

    (apologies I'm not sure how to box off the code for this post)


    Sub FIlterCriteria()
    
             With ActiveWorkbook
    If Sheet12.Range("C6").Value = "TRUE" Then _
    Sheet2.Range("A1:AI1").AutoFilter Field:=1, Criteria1:= "Y"
    If Sheet12.Range("C7").Value = "FALSE" Then _
    Sheet2.Range("A1:AI1").AutoFilter Field:=12, Criteria1:="="
    
    End if
    end sub


    'this macro is looking at my workbook, sheet12, cell C6 and if the value is True, it's going to sheet2 with my table and filtering out the Y from the 1st column. The go back to sheet12, look in cell C7 and if it's value is FALSE then going back to sheet12 to my table and filtering out the blanks from the 12th column. If I run the 2 AutoFilter rows of code on their own they work, but don't seem to with the if statements in.

    Any help appreciated

    Ross
    Last edited by royUK; 04-27-2012 at 10:39 AM.

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