search by keyword

S

SubliminalJones

Hello and "Happy Days off for Celebrating Something...or not".

I was trying to make a macro that would allow me to type a word in A1
and touch an object to do a keyword search based on A1.

Can I do that?


Thanks all!!

SJ
 
N

Norman Jones

Hi Subliminal,

Try assigning the following code to a button::

'=============>>
Public Sub Tester001()
Dim rng As Range
Dim rngFound As Range
Dim sStr As String

Set rng = Range("A1")
sStr = rng.Value

Set rngFound = Cells.Find(What:=sStr, _
After:=Selection, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext)

If rngFound.Address = rng.Address Then
Set rngFound = Cells.FindNext(rngFound)
End If

rngFound.Activate

End Sub
'<<=============

If you were unsure of the required syntax, you would find the macro recorder
an invaluable tool.


---
Regards,
Norman


"SubliminalJones"
 
S

SubliminalJones

Hi Norman,

Thanks for the help. It works good but it gives an error message that
highlights

Set rngFound = Cells.Find(What:=sStr, _
After:=Selection, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext)

in the debugger. It appears to have a problem with

SearchDirection:=xlNext)

Any suggestions?

Thanks again, SJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top