Solved

Keyword searching in ms excel

Posted on 2013-01-14
6
283 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
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 29

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 29

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA modules import 4 57
adding "ungroup sheets" to existing vbs code 5 31
excel table with over 25000 rows. 3 33
Macro show matches 3 26
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…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

821 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