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
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,536
Messages
5,572,767
Members
412,482
Latest member
arooshrana2
Top