Filter Table Based on Cell Value Without Exact Match- VBA

jewkes6000

Board Regular
Joined
Mar 25, 2020
Messages
60
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.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try:"
Criteria1:="*" & Cells(12, 29).Value & "*"
 
Upvote 0
Perhaps:

VBA Code:
Dim bla As String

bla = Cells(12, 29).Value

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

Forum statistics

Threads
1,216,101
Messages
6,128,842
Members
449,471
Latest member
lachbee

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