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
-
ms access report
by Uncle (1 replies)
-
Macro in Excel, and If statement that needs to loop through a range
by Wukkie (0 replies)
-
How to bind more than 1 client in 1 computer to winsock UDP server with ms.access
by esugiawan (0 replies)
-
How to bind more than 1 client in 1 computer to winsock server with ms.access xp
by esugiawan (0 replies)
-
VB6 system conversion using VBA to Word 2007
by b.macgregor@vodamail.co.za (0 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.