Solved

Filtering an Excel Spreadsheet

Posted on 2014-09-05
4
244 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:Iammontoya
Comment Utility
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
Comment Utility
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
Comment Utility
Perfect.
0
 
LVL 27

Expert Comment

by:Glenn Ray
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

763 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

13 Experts available now in Live!

Get 1:1 Help Now