Poo_Drop
12-13-2007, 11:06 AM
I want to sort through a column of names and highlight each cell in the column that contains that name. I have written a formula that will let me do this, but only if the whole cell matches. For example,
Cell(1,1) = Bill
Cell(2,1) = Bill / Jane
My current code will match (1,1) but not (2,1). I hope that makes sense.
Here's my current code:
Sub Find_Yourself()
Dim sRet As String
sRet = InputBox("Please enter your name", "Name")
If sRet Is Nothing Then
Exit Sub
Dim rFoundCell As Range
Set rFoundCell = Range("B1")
For i = 1 To WorksheetFunction.CountIf(Columns(2), sRet)
Set rFoundCell = Columns(2).Find(What:=sRet, After:=rFoundCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
With rFoundCell
.Interior.ColorIndex = 35
End With
Next i
Cells(6, 2).Select
End Sub
Thanks for any help! I've been working on this for about two days now.
Cell(1,1) = Bill
Cell(2,1) = Bill / Jane
My current code will match (1,1) but not (2,1). I hope that makes sense.
Here's my current code:
Sub Find_Yourself()
Dim sRet As String
sRet = InputBox("Please enter your name", "Name")
If sRet Is Nothing Then
Exit Sub
Dim rFoundCell As Range
Set rFoundCell = Range("B1")
For i = 1 To WorksheetFunction.CountIf(Columns(2), sRet)
Set rFoundCell = Columns(2).Find(What:=sRet, After:=rFoundCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
With rFoundCell
.Interior.ColorIndex = 35
End With
Next i
Cells(6, 2).Select
End Sub
Thanks for any help! I've been working on this for about two days now.