Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 56
  • Last Modified:

Hi, issue with searching a set of strings in excel

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
sai k
Asked:
sai k
1 Solution
 
Rgonzo1971Commented:
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
 
frankhelkCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now