Solved

Hi, issue with searching a set of strings in excel

Posted on 2016-10-24
2
38 Views
Last Modified: 2016-11-21
In excel, I have data in column A and I need to search for set of strings in column A. I should get findings in column B.
Ex:
column A                          column B result
Apple                                 no findings
Pen                                    found pen  
pen in the Book               found pen,book
Cat                                     no findings                      
House                                found house
Deer                                   no findings
elephant house               found elephant,house

I need to search pen,book,house,elephant in column A and in corresponding column I have to get found pen,found house.....

I can do this with if condition but the data that I have is huge and so taking lot of time for execution. can this be done with some inbuilt excel functions like search({"pen","house","...},A:A).....????
0
Comment
Question by:sai k
2 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41858061
Hi,

pls try
Sub macro()
aFind = Split("pen,book,house,elephant", ",")
For Each c In Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
strFound = ""
    For Each Item In aFind
        If LCase(c) Like "*" & LCase(Item) & "*" Then
            strFound = strFound & "," & Item
        End If
    Next
    If strFound <> "" Then
        c.Offset(, 1) = "found " & Right(strFound, Len(strFound) - 1)
    Else
        c.Offset(, 1) = "no findings"
    End If
Next
End Sub

Open in new window

Regards
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41895634
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Rgonzo1971 (https:#a41858061)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Modern/Metro styled message box and input box that directly can replace MsgBox() and InputBox()in Microsoft Access 2013 and later. Also included is a preconfigured error box to be used in error handling.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

679 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