ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Search Macro (https://www.excelbanter.com/excel-worksheet-functions/262052-search-macro.html)

Eán[_2_]

Search Macro
 
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.


Jacob Skaria

Search Macro
 
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


--
Jacob (MVP - Excel)


"Eán" wrote:

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.


Eán[_2_]

Search Macro - Command Button
 
How can I do this using the Command Button?

"Jacob Skaria" wrote:

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


--
Jacob (MVP - Excel)


"Eán" wrote:

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.


Jacob Skaria

Search Macro - Command Button
 
--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 ViewToolbarsForms drag a button control to the worksheet. and
select the macro to be assigned....

--
Jacob (MVP - Excel)


"Eán" wrote:

How can I do this using the Command Button?

"Jacob Skaria" wrote:

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


--
Jacob (MVP - Excel)


"Eán" wrote:

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.



All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com