Library code snippets
Adding a Find Button to an Excel Worksheet
By Gravitycure, published on 08 Jan 2002
The following code should be placed in the click procedure of your 'Find' Command Button (in this case it is called FindButton). When the button is pressed, the text that is present in a text box on your worksheet (in this case TextBox1) will be found. If the text does not exist on the worksheet, then an error message is displayed.
Private Sub FindButton_Click()
Dim strFindWhat As String
strFindWhat = TextBox1.Text
On Error GoTo ErrorMessage
Cells.Find(What:=strFindWhat, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Select
Exit Sub
ErrorMessage:
MsgBox ("The data you are searching for does not exist")
End Sub
Related articles
Related discussion
-
Excel 2007 Error : ' the digital signature is deleted when Excel users tries to save the Master Excel Spreadsheet.'
by jdierkes (0 replies)
-
Excel VBA transposition problem
by KDHTSVAU (2 replies)
-
excell question
by Uncle (11 replies)
-
Question about subforms
by ginwah (0 replies)
-
How to change a position of a "line" control in a form based on combo box selection? Please help!!!
by scorpions111 (1 replies)
Thanks for the code.
Used it in VBA, works awesone with some minor tweaking
Thanks a LOT !!!!!
Help me!
How contorl Excel in VB?
thanks.
help me!
This thread is for discussions of Adding a Find Button to an Excel Worksheet.