PDA

View Full Version : Solved: Highlight entire row when item is found.



Marcster
01-13-2006, 04:17 AM
Hello people :hi: ,

I'm trying to write a macro which will find something a user inputs
into an Inputbox. Then highlights the entire row.
So far I have this:



Sub FindThenHighlightWholeRow()
'
' Prompts for input, finds it, then highlights whole row.
'

Dim toFind

toFind = Application.InputBox("What to search for:")

If toFind <> "" Then
Cells.Find(What:=toFind, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
ActiveCell.EntireRow.Activate
End If

End Sub

Although it highlights the found cell it doesn't highlight
the whole row.

I'm most likley missing something simple... :think:

Thanks :thumb,

Marcster.

johnske
01-13-2006, 05:17 AM
Sub FindThenHighlightWholeRow()
'
' Prompts for input, finds it, then highlights whole row.
'

Dim toFind

toFind = Application.InputBox("What to search for:")

If toFind <> "" Then
Cells.Find(What:=toFind, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).EntireRow.Activate
End If

End Sub

Marcster
01-13-2006, 05:38 AM
If toFind <> "" Then
Cells.Find(What:=toFind, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).EntireRow.Activate
End If


The last bit .EntireRow.Activate is what I was missing.

Thanks,

Marcster.