+ Reply to Thread
Results 1 to 4 of 4

Autofiltering on Columns

Hybrid View

  1. #1
    Registered User
    Join Date
    05-02-2011
    Location
    SF, CA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Autofiltering on Columns

    Autofilter allows you to filter data and easily select it from a dropdown box. Unfortunately, it's limited in that it only allows you filter on data within a column and in different rows. I'm wondering if anyone knows a way to do this on data within the same row but to display only the columns that fit a certain criteria.

    For example, if I have the following table:
    \1

    is there any way to create some sort of drop down box to allow the user to only view those columns where criteria C = 1 or C = 2 or whatever the user decides?

    thanks.

  2. #2
    Registered User
    Join Date
    12-21-2010
    Location
    Vancouver
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: Autofiltering on Columns

    I don't think there is a way to filter on rows. You could copy the table and paste special Transpose (turn table other way). Then filter on the column Criteria C

    Hope this helps

  3. #3
    Registered User
    Join Date
    05-02-2011
    Location
    SF, CA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Autofiltering on Columns

    here's what i'm working with now.
    Sub CPS()

    Application.ScreenUpdating = False

    i = 1

    Columns("C:IV").Hidden = False

    If Range("B23") = "All" And _
    Range("B24") = "All" And _
    Range("B25") = "All" And _
    Range("B26") = "All" And _
    Range("B27") = "All" And _
    Range("B28") = "All" And _
    Range("B29") = "All" And _
    Range("B29") = "All" And _
    Range("B32") = "All" Then Exit Sub

    Do While Range("A1").Offset(22, i) > 0
    Range("A1").Offset(22, i).Select

    If Selection.Value <> Range("B23").Value Then
    If Selection.Offset(2, 0) <> Range("B25").Value Then
    If Selection.Offset(3, 0) <> Range("B26").Value Then
    If Selection.Offset(4, 0) <> Range("B27").Value Then
    If Selection.Offset(6, 0) <> Range("B29").Value Then
    If Selection.Offset(7, 0) <> Range("B30").Value Then
    If Selection.Offset(9, 0) <> Range("B32").Value Then ActiveCell.EntireColumn.Hidden = True
    End If
    End If
    End If
    End If
    End If
    End If

    i = i + 1

    Loop

    Application.ScreenUpdating = True

    End Sub
    The rows to be filtered on are 23, 25, 26, 27, 29, 30, 32. For a column to NOT be hidden, it needs to match the filter criteria on each of the rows. The only exception is if the filter criteria for a particular row says "All" in which case that filter row isn't filtered on. The filter criteria are all in Column B while the data begins in column C.

    At this point, my code allows me to filter by one criteria at a time (either row 23, 25, 26, etc.), but I can't seem to figure out how to filter on two criteria simultaneously. The code above shows columns which match at least 1 of the criteria. I want them to match ALL the criteria in order to not be hidden.

    Does this make sense? I can attach a dummy workbook if it doesn't make sense.
    Last edited by hruski; 05-05-2011 at 06:33 PM.

  4. #4
    Forum Contributor
    Join Date
    09-23-2008
    Location
    Mexico
    Posts
    200

    Re: Autofiltering on Columns


+ 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