Solved

Keyword searching in ms excel

Posted on 2013-01-14
6
250 Views
Last Modified: 2013-01-15
I need to do a keyword search in excel, and enter "tags" for approximately 40 keywords in a separate column.   The text to be searched is all in one column.  Some of the keywords will return the same tag, but the tag should only be included one time.

I am attaching a file that can be used for testing, showing the result.

Thanks
test-file-for-experts-exchange-J.xlsx
0
Comment
Question by:tomwaddell
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
I'm looking at the whole file and not sure I understand well what you want.

Are we concentrating on Col E and Their Coresponding Tags in Col F from Row 3 to 13 (that is what I understood from the question raised above).

BUT when I looked further down in your worksheets I see Additional Tags in diffrent Column C to be added which making me confused do you mean you want to add to the above result whatever is in the Column C ???

If yes pls check this first attempt making sure that you enable Macroes and type whatever tag you want in Col E at the row that you want and pressing ENTER should give you the expected result in Col F

Let me know if this is what you want or else pls comment so we can finetune it.
gowflow
test-file-for-experts-exchange-J.xlsm
0
 
LVL 24

Accepted Solution

by:
Steve earned 500 total points
Comment Utility
Here is my effort in the form of a Function:

Function TextCode(StringIn As String, KeyRange As Range, Optional xTags As String) As String

Dim Dic As Scripting.Dictionary
Set Dic = New Scripting.Dictionary
Dic.CompareMode = TextCompare

Dim Dic2 As Scripting.Dictionary
Set Dic2 = New Scripting.Dictionary
Dic2.CompareMode = TextCompare

Dim rng
rng = KeyRange.Value

For x = 1 To UBound(rng)
    If Not Dic.exists(UCase(rng(x, 1))) Then Dic.Add UCase(rng(x, 1)), rng(x, 2)
Next x
StringIn = UCase(StringIn)
For Each i In Dic.Keys
If StringIn Like "*" & i & "*" Then
    If Not Dic2.exists(Dic.Item(i)) Then Dic2.Add Dic.Item(i), Dic.Item(i)
End If
Next i

TextCode = Join(Dic2.Keys, ", ")

If Len(xTags) > 0 Then
    If Len(TextCode) = 0 Then
        TextCode = xTags
    Else
        TextCode = TextCode & ", " & xTags
    End If
End If

End Function

Open in new window


This gives a function in Excel to be used as a normal function:
=TextCode(StringIn, KeyRange, [xTags])
Where StringIn is the starting text
Key Range is the range of Keys used (see key sheet)
xTags are the optional additional tags.

The attached file should show more clearly.
I have only filled some of the key data into the key sheet to get you started.
test-file-for-experts-exchange-J.xlsm
0
 

Author Closing Comment

by:tomwaddell
Comment Utility
Thank you.   Your solution was perfect, and timely.

Tom Waddell
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Expert Comment

by:gowflow
Comment Utility
Did you try the one I posted ?
gowflow
0
 

Author Comment

by:tomwaddell
Comment Utility
Yes.   It works fine with a couple tweaks.   Thanks
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
I Just noticed you needed for it to check Col B which was not mentioned in your original post which column to test.

As a small note for future try working on clarifying what the problem is and what you expect from Experts in your question just before hitting your final GO on the question as this would help waisted time and ensure you get a sharp reply.

In any case here is my solution anyway. Activate the button in Sheet1

gowflow
test-file-for-experts-exchange-J.xlsm
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

12 Experts available now in Live!

Get 1:1 Help Now