Autofilter a table in another sheet based on selected cell value where autofilter needs to be 'contains'

crackod93

Board Regular
Joined
Aug 9, 2007
Messages
71
hi all, firstly i'm not that familiar with VBA so i appreciate any and all guidance i can get from this community with this query I have.

So i've referenced this solution 'https://stackoverflow.com/questions/35231790/clicking-a-hyperlink-in-excel-to-set-autofilter-on-a-different-sheet#', which takes the value from the cell which is double-clicked and then autofilters the target sheet & column to display matches for that value. The only issue is that where the target sheet/column contains additional values in the same cell the autofilter skips it because i think its looking for EXACT matches rather than something like a CONTAINS:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If ActiveCell.Column = 3 Then
Sheet1.ListObjects("target").Range.AutoFilter Field:=17, Criteria1:=ActiveCell.Value
Sheet1.Activate
End If
End Sub

Can anyone please help me to somehow make the autofilter do a CONTAINS the value for matching rather than a having the cells be an EXACT match?

many thanks, David
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try
Code:
Criteria1:="*" & ActiveCell.Value & "*"
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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