Filter for word in multiple columns (with a macro and/or slicer)

marshak

Board Regular
Joined
May 28, 2007
Messages
65
Hello all!

I have a problem that I need solved, and am hoping there is a solution.

PROBLEM: I need to filter for the word "Caputo" in both columns E and F. If I filter column E first, then that will filter out rows that may have "Caputo" in column F.

OPTION 1 (macro): In the current table I created a macro that does what I need it to do (found in columns J and K), however, If i insert a row in the table (for example a row above the A3), my macro no longer works (and the formatting for my macro changes). Can i create a macro that will do what I need, but will not be affected by the additions/deletions of rows and columns to the table?

OPTION 2 (slicer): Can I create a slicer that "sits" on top of the cells, so that no matter what additions and deletions I make in the table -- it will not affect the formatting of the slicer.

Thank you so much in advance!! Please also let me know if I can provide any further explanation.

100478__131356007v5_AEO - Chronology - MACROS ENABLED.XLSM
ABCEFGHIJKLMNOPQ
1DateEventSourcePrimary RelevanceSecondary RelevanceKey Event?Primary RelevanceSecondary Relevance
21995CaputoCaputo
31994-1997CaputoCaputo
41997-2002Caputo
5June 1997-Dec. 2002CaputoKey Event?
62000USRC BackgroundCaputoY
72002CaputoCaputo
88/27/2003Dorsey ConnectionsCaputo
92007
105/30/2007Dorsey ConnectionsCaputo
116/22/2007Dorsey ConnectionsCaputo
127/17/2008Dorsey ConnectionsCaputo
135/7/2009Dorsey ConnectionsCaputo
146/19/2009Dorsey ConnectionsCaputo
1512/4/2009Dorsey ConnectionsCaputo
1612/4/2009CaputoCaputo
1712/21/2009MDAsY
1812/21/2009MDAsY
1912/21/2009MDAsY
201/6/2010MDAsY
21Approx. April 2010Caputo
227/6/2010Dorsey ConnectionsCaputo
238/3/2010Dorsey ConnectionsCaputo
248/16/2010TMs
2511/12/2010Dorsey Connections
2612/17/2010Caputo
271/24/2011MDAsY
283/17/2011Dorsey Connections
298/2/2011Caputo
301/31/2012Dorsey Connections
312/28/2012Caputo
324/16/2012MDAs
335/21/2012MDAsY
Master Chron
Cells with Data Validation
CellAllowCriteria
F6:F33List=Relevance_List
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I'm not clear about whether you want to include rows with Caputo in column E or not. Here's 2 options. Option A includes Caputo in column E and excludes Caputo in column F. Option B excludes Caputo in both columns E and F. Neither macro is affected when you insert a row.

VBA Code:
Sub marshak_A()
    With Worksheets("Master Chron").Range("E:F")
        .AutoFilter 1, "Caputo"
        .AutoFilter 2, "<>Caputo"
    End With
End Sub

VBA Code:
Sub marshak_B()
    With Worksheets("Master Chron").Range("E:F")
        .AutoFilter 1, "<>Caputo"
        .AutoFilter 2, "<>Caputo"
    End With
End Sub
 
Upvote 0
Thanks so much! I'd like to include rows with Caputo in both Columns E and F. Can you please send me that macro? Thanks so much!!
 
Upvote 0
Option C then :)

VBA Code:
Sub marshak_C()
    With Worksheets("Master Chron").Range("E:F")
        .AutoFilter 1, "Caputo"
        .AutoFilter 2, "Caputo"
    End With
End Sub
 
Upvote 0
Thanks so much for your time. I tried entering the created macro and this is the error message that I get. What am I doing incorrectly?

1662598527859.png
 
Upvote 0
See if this one makes any difference:

VBA Code:
Sub marshak_D()
    With Worksheets("Master Chron").UsedRange
        .AutoFilter 5, "Caputo"
        .AutoFilter 6, "Caputo"
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top