Search Macro

E

Eán

Is there a macro of function I can use to find key words or statements on a
worksheet, similat to the Find (goggles) icon?

Many thanks.
 
J

Jacob Skaria

Try the below...If you are looking for a whole cell match; then change LookAt
to xlWhole

Sub Macro()

Dim varFound As Variant, varSearch As Variant

varSearch = InputBox("Find string")
Set varFound = Cells.Find(varSearch, LookIn:=xlValues, LookAt:=xlPart)
If Not varFound Is Nothing Then
varFound.Activate
End If

End Sub
 
E

Eán

How can I do this using the Command Button?

Jacob Skaria said:
Try the below...If you are looking for a whole cell match; then change LookAt
to xlWhole

Sub Macro()

Dim varFound As Variant, varSearch As Variant

varSearch = InputBox("Find string")
Set varFound = Cells.Find(varSearch, LookIn:=xlValues, LookAt:=xlPart)
If Not varFound Is Nothing Then
varFound.Activate
End If

End Sub
 
J

Jacob Skaria

--Set the Security level to low/medium in (Tools|Macro|Security).
--From workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook.

From menu View>Toolbars>Forms drag a button control to the worksheet. and
select the macro to be assigned....
 

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