ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FIND Command (https://www.excelbanter.com/excel-programming/282232-find-command.html)

Neil Shaw

FIND Command
 
Hi

Im using the find command and the findnext. It keeps going in a loop
so when it has gone to the bottom of the range it then goes back to
the top. How can i stops this basically i want to look in a column for
cells with PC in and then set the background color of the row

Thanks Neil

Don Guillett[_4_]

FIND Command
 
As always, post your coding efforts for comments.

--
Don Guillett
SalesAid Software

"Neil Shaw" wrote in message
om...
Hi

Im using the find command and the findnext. It keeps going in a loop
so when it has gone to the bottom of the range it then goes back to
the top. How can i stops this basically i want to look in a column for
cells with PC in and then set the background color of the row

Thanks Neil




Stuart[_10_]

FIND Command
 
capture the address of the first find, then test subsequent finds for the
same address



Neil Shaw wrote in message
om...
Hi

Im using the find command and the findnext. It keeps going in a loop
so when it has gone to the bottom of the range it then goes back to
the top. How can i stops this basically i want to look in a column for
cells with PC in and then set the background color of the row

Thanks Neil




Mike Q.[_2_]

FIND Command
 
I am new at this stuff myself but if I understand your
question this might help. It is case sensitive and will
highlight from column A to eterity. I hope you can fix it
right.

Option Explicit

Sub PCYELLOW()

Dim FoundCell As Range
Dim firstAddress As String
Dim myWord As String
Dim YellowCell As Range

myWord = "PC"
With ActiveSheet.Cells
Set FoundCell = Nothing
Set FoundCell = Cells.Find(What:=myWord,
LookAt:=xlWhole, SearchOrder _
:=xlByRows, MatchCase:=True)

If Not FoundCell Is Nothing Then
firstAddress = FoundCell.Address

Do
If YellowCell Is Nothing Then
Set YellowCell = FoundCell
Else: Set YellowCell = Union(FoundCell,
YellowCell)
End If
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < firstAddress
End If
End With

If YellowCell Is Nothing Then Exit Sub
YellowCell.EntireRow.Interior.ColorIndex = 6
YellowCell.EntireRow.Interior.Pattern = xlSolid
End Sub

-----Original Message-----
Hi

Im using the find command and the findnext. It keeps

going in a loop
so when it has gone to the bottom of the range it then

goes back to
the top. How can i stops this basically i want to look in

a column for
cells with PC in and then set the background color of the

row

Thanks Neil
.



All times are GMT +1. The time now is 02:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com