autofilter partial match

tbettar

New Member
Joined
Aug 31, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I'm new to visual basics and I'm trying to filter my data so it will show up as the User searches for it. However, I want the User to be able to search for partial matches.

Example: Product Number in the table is 1234567
I want the User to be able to simply search for 123 and the item with the 1234567 Product Number to show up.

Example: Name in the table is John Smith
I want the User to be able to simply search for John and all names that include John to show up.

So I would need a partial match for AutoFilter.

This is what I have:

If FieldName = "Product Number" Then
'filter by Product Number
MyTable.Range.AutoFilter Field:=1, Criteria1:=UserInput

ElseIf FieldName = "Area" Then
'filter by Area
MyTable.Range.AutoFilter Field:=2, Criteria1:=UserInput

ElseIf FieldName = "Name" Then
'filter by Name
MyTable.Range.AutoFilter Field:=5, Criteria1:=UserInput

This code only work if the user searches for the exact cell content.

Thank you!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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