Solved

Keyword searching in ms excel

Posted on 2013-01-14
6
296 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 30

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 30

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 30

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

738 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