Solved

Filtering an Excel Spreadsheet

Posted on 2014-09-05
4
248 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article will show, step by step, how to integrate R code into a R Sweave document
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

912 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now