Filter Table Based on Cell Value Without Exact Match- VBA

jewkes6000

Board Regular
Joined
Mar 25, 2020
Messages
55
Office Version
  1. 365
Platform
  1. Windows
I am trying to filter a table based on the contents of a certain cell value using a macro. I have something which partially works; however, I want to be able to filter the table if the contents in the specified cell (AC12) are contained in the table. For example, if AC12 contains "R&D", but the column in table has cells which read "Office, R&D", I still want to see the row which contains "Office, R&D". Here is the code I have:

Code:
Sheets("Setup Page").Range("Z26").AutoFilter Field:=5, Criteria1:=Cells(12, 29).Value

Essentially, I'm looking to find out how to make the value in "Cells(12,29)" a wildcard rather than an absolute value (not sure if I'm using correct terminology here).

Thank you in advance for any help.
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,414
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Try:"
Criteria1:="*" & Cells(12, 29).Value & "*"
 

mrshl9898

Well-known Member
Joined
Feb 6, 2012
Messages
1,720
Perhaps:

VBA Code:
Dim bla As String

bla = Cells(12, 29).Value

Sheets("Setup Page").Range("Z26:Z30").AutoFilter Field:=1, Criteria1:="*" & bla & "*"
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,127,876
Messages
5,627,418
Members
416,245
Latest member
Xterminat

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
Top