ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command button to search column (https://www.excelbanter.com/excel-programming/276405-command-button-search-column.html)

Al[_7_]

Command button to search column
 
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

Steve Smallman

Command button to search column
 
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
"Al" wrote in message
...
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




Tom Ogilvy

Command button to search column
 
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.
--
Regards,
Tom Ogilvy

"Al" wrote in message
...
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





All times are GMT +1. The time now is 09:29 PM.

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