Filter Macro where cell contains

Domroy

Board Regular
Joined
Mar 8, 2018
Messages
88
Hi there,

I have a sheet with 1500 records I'm trying to match to another sheet that has 700 records. The company name is not an exact match, so VLOOKUP is not an option. I built a tool with a macro for an advanced filter, and one to clear the data. The problem is that my filter is only looking up the company name if it STARTS with the text I put in my input cell. I want it to find it if it's anywhere in the column, not just the beginning. For example, if I put "National" in the designated lookup cell, I want it to find anywhere where "National" is in the company name field, not just at the beginning. Here's the code I used:

Code:
Sub Filter_Data()
'
' Filter_Data Macro
'


'
    Application.ScreenUpdating = False
    Application.CutCopyMode = False
    Range("List").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range( _
        "Criteria"), Unique:=False
End Sub
Sub Reset_Filter()
'
' Reset_Filter Macro
'


'
    Application.ScreenUpdating = False
    Range("A4").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range("A4:XFB4").Select
    Range(Selection, Selection.End(xlToLeft)).Select
    Range("A4:N4").Select
    Selection.ClearContents
    Application.CutCopyMode = False
    Range("List").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range( _
        "Criteria"), Unique:=False
    Range("A4").Select
End Sub
Can you help me fix it so it finds the data wherever it's located in the cell?

Thank you!

Judi
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,262
Office Version
2013
Platform
Windows
Try putting the keyword between 2 asterisk, like this:
*National*
 

Domroy

Board Regular
Joined
Mar 8, 2018
Messages
88
Try putting the keyword between 2 asterisk, like this:
*National*
OH!!! As in, in my search box? YES! I will try that tomorrow when I get to work and let you know. Thanks so much! I always forget about those...
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,262
Office Version
2013
Platform
Windows
Ok, glad it works.:)
 

Forum statistics

Threads
1,078,447
Messages
5,340,345
Members
399,370
Latest member
salamon

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top