search word in each cell

G2K

Active Member
Joined
May 29, 2009
Messages
355
Hi all,


i have data sheet containing customer feedback, column H of this sheet contians feedback text. there are 4500 rows and i have to search 12 keywords in each cell(H2 t0 H4500). the key words are -

Unhappy
Declined
Dissatisfied
Frustrated
Frustrating
Unreasonable
Increase in margin
Competitor
Error
Bad
Charges
Mistake.

if any of these or more than one word found in respective cell then macro should return the text in Adjucent right cell.

thanks in advance
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
WIth your list of 12 keywords in A1:A12, try this to check H2

=IF(ISNA(LOOKUP(9.99999999999999E+307,SEARCH(" "&$A$1:$A$12&" "," "&$H2&" "),$A$1:$A$12)),"-",VLOOKUP(LOOKUP(9.99999999999999E+307,SEARCH(" "&$A$1:$A$12&" "," "&$H2&" "),$A$1:$A$12),$A$1:$B$12,2,0))
 
Upvote 0
Hi
With keywords in col A (any number of words) try the following codes
Code:
Sub G2K()
Dim x As Long, y As Long, a As Long, b As Long
x = Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
y = Sheets("sheet1").Cells(Rows.Count, 8).End(xlUp).Row
Sheets("sheet1").Range("I:I").ClearContents
    For a = 2 To y
        For b = 1 To x
            If InStr(Cells(a, 8), Cells(b, 1)) > 0 Then
            Cells(a, 9) = Cells(a, 9) & ", " & Cells(b, 1)
            End If
        Next b
        Cells(a, 9) = Right(Cells(a, 9), Len(Cells(a, 9)) - 1)
    Next a
MsgBox "Complete"
End Sub
matching terms will be in col I (9)
Ravi
 
Upvote 0
thanks Yard/Ravi for your quick and correct Reply

formula is working absolutely fine

i am geting an error in below line of sub()

Cells(a, 9) = Right(Cells(a, 9), Len(Cells(a, 9)) - 1)

as given cell is blank. there is no data in Column I. we remove contentns of this column before we move to compare these string.

Please check.

thanks again
 
Upvote 0
Posted By Ravi-

Hi
With keywords in col A (any number of words) try the following codes
Code:


Sub G2K()
Dim x As Long, y As Long, a As Long, b As Long
x = Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
y = Sheets("sheet1").Cells(Rows.Count, 8).End(xlUp).Row
Sheets("sheet1").Range("I:I").ClearContents
For a = 2 To y
For b = 1 To x
If InStr(Cells(a, 8), Cells(b, 1)) > 0 Then
Cells(a, 9) = Cells(a, 9) & ", " & Cells(b, 1)
End If
Next b
Cells(a, 9) = Right(Cells(a, 9), Len(Cells(a, 9)) - 1)
Next a
MsgBox "Complete"End Sub
</PRE>
matching terms will be in col I (9)
Ravi



Thanks for your help,

i have made few changes in given code, and it's working perfactly fine now

For a = 2 To y
For b = 1 To x

If InStr(UCase(Cells(a, 8)), UCase(Cells(b, 1))) > 0 Then
Cells(a, 9) = Cells(a, 9) & ", " & Cells(b, 1)
End If
Next b

If (Len(Cells(a, 9)) > 0) Then
Cells(a, 9) = Right(Cells(a, 9), Len(Cells(a, 9)) - 2)
Else
Cells(a, 9) = "-"
End If
Next a

as instr was not able to find keywords in diffrent cases(lower/Upper/Regular).

thanks again guys for your kind help

Regards
G2K:)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top