PDA

View Full Version : keyword search



Tharabai
09-13-2015, 10:01 AM
Hi,

I have few keywords (nearly 20) in a separate sheet named "Keyword". I have to search for the list of words(eg.. awards, prize, award, prizes, gift, gifts..) in the sheet1 of column X.

I need not find the exact word, even if it contains the result should be displayed.

Search for keyword and the displayed results to be copied to the "results" sheet one by one after the last used row of result sheet.

-Tharabai

werafa
09-13-2015, 04:01 PM
try 'InStr' this is the 'In-String' command, and will return the position of your keyword in the text string to be searched.

Create an array of search strings
create an array of 'words'
Create a routine to loop through each search string and test each 'word'

Tharabai
09-13-2015, 07:27 PM
Hi, Thank you for the response. I have used the below code but small issue with this code. For the first search it should copy with the headers and after that only the results of search in "result" sheet after the last used cell.



sub search()

lastSrc_rw = Sheets("Keyword").Range("A" & Rows.Count).End(xlUp).Row
MsgBox lastSrc_rw

For Each ksearch In Sheets("Keyword").Range("A1:A" & lastSrc_rw)
With Sheets("Sheet1").Columns(53)
Set c = .Find(car, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
firstAddress = c.Address
Do

nxtDst_rw = Sheets("Keyword_Result").Range("A" & Rows.Count).End(xlUp).Row + 1
c.EntireRow.Copy Destination:=Sheets("Keyword_Result").Range("A" & nxtDst_rw)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Next
End sub

snb
09-14-2015, 12:00 AM
Use autofilter or advancedfilter.

Tharabai
09-14-2015, 10:33 AM
Can the above coding be edited to suit my requirement... only the header is missing in the result. First result should be copied with the header..

werafa
09-15-2015, 04:11 PM
Create a separate routine to copy the header in. This is a separate task.