Macro to find a item

Seanzies

Board Regular
Joined
Nov 19, 2005
Messages
212
I am in need of a Macro to find an item that will search the entire workbook.
But the item that they are searching for will be different everytime. I would like a dialog box to open with they click a button. I just need the macro. I can later assign it to the button.

I want it to work like the Edit - Find option but when you click the button a dialog box opens asking you to enter an item that you want to find.

Can anyone help? This is what i have so far but it doesn't bring up a window to enter in an item.
Code:
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

sweater_vests_rock

Well-known Member
Joined
Oct 8, 2004
Messages
1,657
This adds a dialog box:

Code:
Dim FindText as String

FindText = Application.InputBox("Enter the text you wish to find: ", "Find Text", type:=2)

Cells.Find(FindText, LookIn:=xlValues)

cheers. ben.
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Why not just use the actual Edit | Find dialog box? You don't need code for that.

Tools | Customize.. | Commands (tab) | Edit (on left) | Find (on right). Click and drag it to whatever toolbar you want. Voila!
 

Seanzies

Board Regular
Joined
Nov 19, 2005
Messages
212
Ben, first of all thanks!

How can I make it search all sheets, (ie Sheet2 & Sheet3)
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
This is all done natively .. searching the entire workbook is an option in the Find dialog box .. with 2003, you already have all this.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,805
Messages
5,833,773
Members
430,232
Latest member
Testsubject

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
Top