Simple Macro Question

B

Beginner

Quick question that I am having a problem on:

How do I write visual basic code in my macro to have it FIND a certain word (ie. "mouse") in a worksheet and then have it select that entire row the found word is in (without manually typing in the number that row is in.... this worksheet is large and needs to be split into certain words on added worksheets)?

Thanks so much! I greatly appreciate anyone that can help!!
 
B

Bob Greenblatt

Quick question that I am having a problem on:

How do I write visual basic code in my macro to have it FIND a certain word
(ie. "mouse") in a worksheet and then have it select that entire row the found
word is in (without manually typing in the number that row is in.... this
worksheet is large and needs to be split into certain words on added
worksheets)?

Thanks so much! I greatly appreciate anyone that can help!!


Try this:

Sub FindWord()
Cells.Find(What:="Mouse", LookAt:=xlWhole).EntireRow.Select
End Sub
 
J

JE McGimpsey

Bob Greenblatt said:
Try this:

Sub FindWord()
Cells.Find(What:="Mouse", LookAt:=xlWhole).EntireRow.Select
End Sub

And if the word might not exist on the sheet:

Public Sub FindWord()
Dim rFound As Range
Set rFound = Cells.Find(What:="Mouse", LookAt:=xlWhole)
If Not rFound Is Nothing Then
rFound.EntireRow.Select
Else
MsgBox """Mouse"" was not found."
End If
End Sub
 
Top