Command button to search column

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

I have not coded in Excel before but have done some in
Access. I recently received a request to do the following:

In an Excel 2000 spreadsheet, I would like to be able to
press a command button, bring up a textbox that asks the
user for part of a search string for column "B" (can it
use wildcards?), and finally, go to the row where the
searched value exists.

TIA,
Al
 
Al,


Sub Find_in_column_B()
Dim FindString As String

FindString = InputBox("Enter string to find, use '?' and '*' as
appropriate", "Find what in column B")
Columns("B:B").Select
Selection.Find(What:=FindString, After:=ActiveCell, LookIn:=xlFormulas,
_
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
End Sub

Then Assign it to a button on a user toolbar (open Excel help in the Answer
Wizard and enter "assign a macro to a button")

Steve
 
The built in Find command does this

you can display that dialog with

Private Sub CommandButton1_Click()
Columns(2).Select
application.Dialogs(xlDialogFormulaFind).Show
End Sub

or just use the shortcut key Ctrl+F

Yes, you can use wildcards.

If it finds the target, it will select the cell.
 
Back
Top