Solved

Keyword searching in ms excel

Posted on 2013-01-14
6
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 31

Expert Comment

by:gowflow
ID: 38777286
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
ID: 38777298
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
ID: 38778884
Thank you.   Your solution was perfect, and timely.

Tom Waddell
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:gowflow
ID: 38779127
Did you try the one I posted ?
gowflow
0
 

Author Comment

by:tomwaddell
ID: 38779197
Yes.   It works fine with a couple tweaks.   Thanks
0
 
LVL 31

Expert Comment

by:gowflow
ID: 38779406
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

623 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