Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Filter Results in Excel to Show Only Those that End With Specified Text or Words - AutoFilter


Bookmark and Share

This free Excel macro filters data to display results that end with certain words, text, or characters. This is a very easy to use and helpful macro in Excel which allows you to quickly and easily display subsets of data in Excel.

It is important to note that in order to properly use this macro you must replace the "Enter Criteria Here" with the text or characters which you want to filter the data by. However, make sure that you do not remove the "*" from the beginning of that text because that is what makes this macro work.


How Filter Macros Work

All of the elements below often appear within autofilter macros.

Range
    This should be the start of the data set, table, or list which you would like to filter. This can also be the entire range reference to the table. For example, if the table was from cell A1:D450, you could put that as the range or you could put A1 as the range. You can do this because the autofilter feature in Excel will automatically try to determine the total range which you would like to filter.
Field
    This is the number of the column within the data table that you would like to filter. The first field (1) is the very first column in the data set that will be filtered. This means that if your data starts in column B and your range is Range("B1") and you want to filter based on column D, you would put 3 in for the field.
Criteria
    This is the criteria by which you would like to filter. Some of the macros have symbols within the quotation marks after this argument and those symbols (such as <,>,*,?, etc.) should be left where they are in order to retain the functionality of the macro.
Operator
    You will not have to change this. This is simply the way to perform different types of filter features in Excel.
Where to install the macro:  Module

Excel Macro to Filter Results in Excel to Show Only Those that End With Specified Text or Words - AutoFilter

Sub AutoFilter_Ends_With()
'Put the * mark before the word in which you would like to filter for this macro

Range("A1").AutoFilter Field:=1, Criteria1:="*Enter Criteria Here"

End Sub


Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

      For Excel Versions Prior to Excel 2007
      Go to Tools > Macros > Visual Basic Editor

      For Excel 2007
      Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
    5. Go to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Excel Vba: Display Excel Autofilter Criteria. Show Auto Filter Criteria In Excel - Excel

View Content
This topic on Ozgrid provides just what I need, but limited to only 2 criteria - my VBA is not up to extending the code to the ten criteria that I need. Can anyone point me in the right direction please? VB:

Function AutoFilter_Criteria(Header As Range) As String  Dim strCri1 As String, strCri2 As String        Application.Volatile            With Header.Parent.AutoFilter          With .Filters(Header.Column - .Range.Column + 1)                        If Not .On Then Exit Function                                strCri1 = .Criteria1              If .Operator = xlAnd Then                  strCri2 = " AND " & .Criteria2              ElseIf .Operator = xlOr Then                  strCri2 = " OR " & .Criteria2              End If                        End With      End With                AutoFilter_Criteria = UCase(Header) & ": " & strCri1 & strCri2  End Function 


If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines



Use Autofilter To Filter Results Using Criteria From Cell Value In Another Worksheet - Excel

View Content
I am trying to use VBA code to filter data. The filter criteria is based on the cell values in another worksheet. The code works when my criteria only includes less than and greater than but when i try to include 'is equal to' or greater than the code doesn't filter like I need it to.

Here's the code:
VB:

ActiveSheet.AutoFilterMode = False 
Range("A1:X1").AutoFilter 
Range("A1:x1").AutoFilter field:=1, Criteria1:=ThisWorkbook.Worksheets("CONWAY").Range("B1").Value, _ 
Operator:=xlAnd 
Range("A1:D1").AutoFilter field:=2, Criteria1:="=" & ">" & ThisWorkbook.Worksheets("CONWAY").Range("C1").Value 'greater than filter to Contract ("B2" as criteria)
Range("A1:x1").AutoFilter field:=3, Criteria1:="=" & "<" & ThisWorkbook.Worksheets("CONWAY").Range("C1").Value 'less than filter to Op Code ("C2" as criteria)


If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines



How Do I Show The Results Of Filter? - Excel

View Content
I'm using Excel 2000. I have a worksheet that gives me the right filtered
records. The problem that I'm having is that I do not see the number of
records that meet the filtered condition. I thought this feature can be
turned on by by right-clicking over the Filter Mode text on the bar at the
bottom of Excel. That hasn't work. So, how do I get the results of a filter
to show?
--
Bob


Need To Filter Results, Add Results And Group The Results In Excel 2007 - Excel

View Content
Hello All,

First time poster. I have a large Excel Spreadsheet that has 32 columns and over 50,000 lines of data. Column U has a 4 digit code. There are over 100 different codes in column U. I want Excel to create a new worksheet where each code is only listed once but the contents are summated. Might be easier to show an example.

Here is how the data appears now:

Column U Column X

AAAA $10
AAAA $20
AAAA $50
AAAA $10
AAAA $100
BBBB $20
BBBB $10
BBBB $50
CCCC $80
CCCC $90

Here is the format I want excel to create:

AAAA $190
BBBB $80
CCCC $170

Thanks, Bill

Need Formula Or Filter To Show Final Results Data - Excel

View Content
I'm doing some database work but I'm having a problem eliminating some data. I need a way to eliminate all of the fields that cancel out each other. For example, I have provided a sample of data below. In my sample, -1 will cancel out with 1, -2 will cancel out with 2, etc. Ultimately, I need the final list to only show data that doesn't cancel itself out. Hope this sounds clear.

-1
-2
-3
-3
1
2
3
4
5
6

Finding Words In Text And Show Found Word - Excel

View Content
I have an excel table with text (In the first column I have sentences of text in each cell).
Also, I have a seperate lookup table with predefined words.
What I want is to look in each cell of text in the table to find if one or more of the words from the lookup table is/are in the text.
Then, if one or more of the words are found in the text, I want that word or words to be presented in the cell next to the column with text.


For example:
Predefined Lookup table (with words):
Here
This
test
Nice
today
*Mult*

Table with text:
Column 1:
Here I am
This is a test
Nice weather today
Multiple ways to Rome

Column 2 (Found words):
Here
This, test
Nice, today
Multiple

As you can see the words from the lookup table that are found in the text are shown in the corresponding row of column2.

Question: which formula do I need for column 2? If possible the formula should also preferably be not case sensitive and if possible I should be able to use wild cards in the words in the lookup table.
Anyone that can resolve this challenge?

Filter For Multiple Text Words - Excel

View Content
I have a long list of item descriptions that I need to filter down to descriptions containing words like "valve" or "ring" or "root" or "epic" (17 key words in all). The basic custom filter looks like it only lets me filter for 2 words.

I have some experience working with advanced filter for things like >100 but that's about it. Any help with this would be so appreciated.

Rank Results To Also Show Text - Excel

View Content
hi all,

so I am building a racing scoring chart, I need to range a set of cells and bring back the order of placings, but I also need to show the following when they appear "DNF" needs to read as "DNF" "DNS" needs to read as "DNS" when it is blank it will error so I have written an error formula to avoid this, I would like to write something else like an IF that vbrings back "" if it errors
The current formula I have works for everything but "DNS"
=IFERROR(IF(J3="DNF",J3,RANK(J3,$J$3:$J$32,1),"")
If someone could help with this i would be most grateful.

James

Use A Text Box To Calculate And Show Results In A User Form - Excel

View Content
I think this is a simple operation but I can not find the way to do it.
I have a excel user form with 3 text boxes, tb1, tb2 and tb3. I want to use
tb3 to show the results of the enteries made in tb1 & 2. For example
tb1 = Maximum
tb2 = Minimum
tb3 = Maximum - Minimum
After the entry is made in tb2 then tb3 will automatically show the
calculated result as the user will not be allowed to move onto that textbox.
At this point the record wil is part of a larger form and not updated to the
worksheet.

Regards


Insert Specific Text Into Cell Based On Filter Results - Excel

View Content
Ok. Here's my problem. I have a spreadsheet that I use which filters on 6 different filter criteria and copies the result set of each filter criteria to a separate worksheet. However, on occasion there are no results found for a given criteria.

What I want to do is when no results are found for a given criteria to return the words "No Data Found" to a cell on a different spreadsheet.

I'm trying to find the correct syntax for:

VB:

If SpecialCells = "" Then 
     
    Sheet("Smith").Select 
    Range("C2").Select 
    ActiveCell.FormulaR1C1 = "No Data" 


If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines



I do know that SpecialCells represents Filtered Records but that's about all I know what to do with that.

Any ideas?

Thanks guys.
Random Tutorials
Goal Seek Feature in Excel
(Intermediate)
Extract Text from Cells - Intermediate Example
(Intermediate)
Lookups With MATCH() and INDEX() Functions
(Intermediate)
IF Statement Introduction & Using Nested IF's
(Easy)
Function and Formulas Lookup in Excel
(Easy)
AND(), OR(), and IF() Statements/Formulas
(Intermediate)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com