Wildcard Operators in VBA

bino1121

New Member
Joined
Apr 26, 2023
Messages
14
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
Platform
  1. Windows
I have a workbook going right now that has 2 sheets. Sheet1 is a data set. Sheet2 is a list of buildings. So far I have it so that the advanced filter is used so that the dataset on Sheet1 is filtered based on the values in Sheet2. My question is can I some how incorporate a line of code to make it so that Wildcards can be used so that only the exact values will be returned and not values that include part of it? For example: I want to filter out only building 1. But I have Building1, Building1A, Building1B, Bulding1C in my list. In the case of my current code the filter will return all those values when I filter by building1. Using wildcards I could get the exact building when filtering to be just Building1.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try to build an advanced filter that follows the pattern in the image.

Zrzut ekranu.png


Artik
 
Upvote 0
For now, I have given you a hint on how to build a filter criterion. As you can see in the image, the criterion is not the cell into which you write the text you are looking for, but a formula (in cell G2) that compares the text you entered (cell E1) with the first cell of the source data (cell A2). When using formulas as a filtering criterion, the criterion's header row should be left blank or contain a name that does NOT appear in the headers of the source table.

If you have trouble adapting my hint attach a workbook with the actual data layout (but change the sensitive data). Since this forum does not allow you to add workbooks as attachments to a post you will need to make the workbook available in some other way, such as through OneDrive or other hosting.

Artik
 
Upvote 0

Forum statistics

Threads
1,215,103
Messages
6,123,112
Members
449,096
Latest member
provoking

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