+ Reply to Thread
Results 1 to 7 of 7

VBA Autofilter

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-04-2016
    Location
    Newcastle
    MS-Off Ver
    2016
    Posts
    107

    Re: VBA Autofilter

    Basically when i filter Column A to "Y" it will only show the cells that contain "Y", as you'd expect. However i also want any cell that has a value in it in column B to not be effected by the filter in column A.

    With the aim of making my sheet look something like this:
    1.png

  2. #2
    Registered User
    Join Date
    04-29-2016
    Location
    Portugal
    MS-Off Ver
    2007
    Posts
    43

    Re: VBA Autofilter

    Well, it's weird I'm not finding anything but I'm not sure if it's possible using the filters because I can't find a way to do it manually (without VBA) so maybe using some loops.
    I'm gonna see if I get anything. You need something like:
    .Range("A1:B1").AutoFilter Field:=1, Criteria1:=("Y"), xlOr, Field:=2, Criteria1:=("*")
    the problem is that the xlOr only seems to work with different criterias, not different columns/fields...
    Last edited by rdrmdr; 05-11-2016 at 06:15 AM.

  3. #3
    Registered User
    Join Date
    04-29-2016
    Location
    Portugal
    MS-Off Ver
    2007
    Posts
    43

    Re: VBA Autofilter

    The only thing I got is this:
    Sub Button1_Click()
        For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
            If Cells(i, 1) <> "Y" And Cells(i, 2) = "" Then Rows(i & ":" & i).EntireRow.Hidden = True
        Next i
    End Sub
    It works, but you will have to work with it for different situations. Cells(Rows.Count, "A").End(xlUp).Row is to get the last cell on column A with something written (in this case, 11)...

  4. #4
    Forum Contributor
    Join Date
    01-04-2016
    Location
    Newcastle
    MS-Off Ver
    2016
    Posts
    107

    Re: VBA Autofilter

    Thanks, this looks like it might be the solution i'm after, i'm going to attempt applying it to the real version of my sheet now

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy top cell post autofilter and re-apply autofilter based on cell value
    By gpato in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-20-2014, 09:07 PM
  2. Replies: 4
    Last Post: 03-16-2013, 08:33 AM
  3. Replies: 2
    Last Post: 07-06-2012, 11:42 AM
  4. in vba how to turn off autofilter also how to check if autofilter is on
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-31-2011, 10:04 AM
  5. AutoFilter method of Range class failed - Yet autofilter works.
    By Carlsbergen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2009, 05:43 PM
  6. Capturing the Excel AutoFilter Sorting Event-sort and autofilter options
    By Kognyto in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2008, 05:36 PM
  7. [SOLVED] How to Sort within AutoFilter with Protection on (and AutoFilter .
    By giblon in forum Excel General
    Replies: 1
    Last Post: 02-16-2006, 08:25 AM

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