Solved

Filtering an Excel Spreadsheet

Posted on 2014-09-05
4
270 Views
Last Modified: 2014-09-05
I have a spreadsheet with about 30000 rows in it.  One of the columns in the spreadsheet has comments from our employees to document communications with our customers.  I need to create a new spreadsheet with all of the columns for all rows where column E contains any of the following:  price, cost, margin, percent, match, competitive, quote.  I am stumped on how to do this.  I basically want to say show me rows that column E contains the word price or cost or margin or percent or match or competitive or quote.

How can I do this?
0
Comment
Question by:9thTee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 19

Expert Comment

by:Montoya
ID: 40306172
You could do it with power pivot. You could also apply table formatting which gives you filter rows
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 40306193
One way that I've done things like this is to add a new column that searched for the requested matches, then filter on that column.

For example, if the source data is in column A, insert column B with a formula like this:

=IF(NOT(ISERR(FIND("price",A1))),1,     IF(NOT(ISERR(FIND("cost",A1))),1,   0)   )

Replace the last "0" with additional IF's for each word.
Any formula that returns a non-zero will contain at least one of the words.  Filter on non-zeros and you have your list.

However, given the complexity of that, it might be easier to user a VBA function to do all that work for you and your formulas will look much better, like =HASMATCHINGWORD(A1)
0
 

Author Closing Comment

by:9thTee
ID: 40306438
Perfect.
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40306558
You could also use VBA to create a user-defined function that would let you know if any one of a select group of key words appeared in the comments column.
Function Find_Matches(Test_Cell As Range, Lookup_array As Range) As String
    Dim cl As Object
    For Each cl In Lookup_array
        If InStr(1, Test_Cell, cl.Value, vbTextCompare) > 0 Then
            Find_Matches = Find_Matches & cl.Value & ", "
        End If
    Next cl
    If Find_Matches <> "" Then
        Find_Matches = Left(Find_Matches, Len(Find_Matches) - 2)
    Else
        Find_Matches = "NOT FOUND"
    End If
End Function

Open in new window


You add this function to a new module in your workbook (VBA Project).

Then, create a list of target words that you want to search for (I recommend a table on another sheet). Then, add a new column adjacent to your data and insert the following formula:
=Find_Matches(test_value,search_range)
where
test_value is the comment cell you want to test
search_range is the range of cells containing the target words.

For example, I put a list of your words on a new sheet called "Words" in cells A2:A8.  If the comments are in column E, then add this formula in column F (cell F2, and copy down)
=Find_Matches(E2,Words!$A$2:$A$8)

Any and all matching words will be displayed in this cell (even more than one), otherwise it will display "NOT FOUND".  You can then turn on filtering and uncheck the "NOT FOUND" results to see all your relevant data.

The nice thing about this function is that you can change your list of target words and the results will automatically update.

Example file attached.

Regards,
-Glenn
EE-FindMatches2.xlsm
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question