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
 

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

Top