Solved

Keyword searching in ms excel

Posted on 2013-01-14
6
263 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

911 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

22 Experts available now in Live!

Get 1:1 Help Now