0

I have a table with a column 4 that contains a bunch of different genres:

enter image description here

I would like to make something that can filter the column based on genres I choose. This is what I have so far:

enter image description here

In a different sheet, there are checkboxes for each different genre (in this example only 3 genres) and by clicking on the checkboxes, the string in cell C2 adds the name of the genre in such a way so that it can be used to filter column 4 in the table.

My issue is that now that I have my desired filter in cell C2, I want to apply this search string to the column to filter out the rows, as if I was doing it manually like this:

enter image description here

So when I click on the "Filter" button (in the second image) this search string gets applied from cell C2 and filtered out.

This is what my macro for the Filter button looks like so far:

Private Sub CommandButton1_Click()
    Worksheets("TableSheet").ListObjects("Table1").Range.AutoFilter Field:=4, Criteria1:= _
    Worksheets("GenrePick").Range("C2").Value
End Sub

Where sheet "TableSheet" contains the table I want to filter in, and sheet "GenrePick" is the sheet where I choose the genres to filter by.

This current macro filters out all rows and doesn't match with the rows that fit the criteria.

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
WoeIs
  • 1,083
  • 1
  • 15
  • 25
  • `gives me the error "Sub or Function not defined"....` You have a typo... `Worksheet` should be `Worksheets` – Siddharth Rout Apr 20 '19 at 19:31
  • Voted to close the question as `This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting.` – Siddharth Rout Apr 20 '19 at 19:31
  • @SiddharthRout, thanks, however this didn't solve the problem fully since it just filters out all of the rows and not the ones that match the search string. – WoeIs Apr 20 '19 at 19:37
  • It will filter out all the text that doesn't match the words in a sequence. So "a,b,c" is not same as "b,a,c" or "a,b,c,d" – Siddharth Rout Apr 20 '19 at 19:39
  • 1
    Is [THIS](https://stackoverflow.com/questions/32540244/filter-a-range-with-values-which-i-dont-want) what you are trying by any chance? – Siddharth Rout Apr 20 '19 at 19:45
  • @SiddharthRout, not quite, but I do believe that I found a solution to my problem. If I rewrote the search string as \*Action\*Comedy\*Supernatural\*, then it is able to pick up all of these words that appear (order doesn't matter since it's all alphabetical in the table. – WoeIs Apr 20 '19 at 19:48

0 Answers0