How to write code for find a word in excel?

  • Thread starter Thread starter Mx
  • Start date Start date
M

Mx

For example , there is two textbox and one command button.
If i press the command button the text entered in the first textbox
will find in xlworkbook and shown in second textbox with a msgbox ?
All sugestions are welcomed.
 
Attach the following macro to a Forms button:

Sub mx_sub()
Dim s As String, t As String
t = Chr(10) & Chr(10)
s = Application.InputBox("Enter the Word: ")
For Each r In ActiveSheet.UsedRange
With r
If InStr(1, .Value, s) > 0 Then
MsgBox ("Found the Word in cell " & .Address & t & .Value)
Exit Sub
End If
End With
Next
MsgBox ("Did not find the Word")
End Sub
 
Dear,

Thanks to Reply my question? Could explain how the code works?

Ya sure I try your coding and i get my result.

Once again thank you.

_ Jawahar S_
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top