Hi Christiane,
Try this
With Worksheets("unit forecast").Range("A1:U50")
On Error Resume Next
Set oCell = .Find(what:="totals", lookat:=xlPart)
If Not oCell Is Nothing Then
sFirst = oCell.Address
Do
oCell.Offset(1, 0).Font.ColorIndex = 3
Set oCell = .FindNext(oCell)
Loop While Not oCell Is Nothing And oCell.Address < sFirst
End If
End With
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Christiane " wrote in message
...
Hi.
This loop is driving me nuts.
I want to search in a range ("A1:U50") to find cells containing the
word "totals" (there is other text in the cell);
when I find such a cell, I want to apply certain formatting to a cell
below it (this part I am ok with).
WHen it finds all the cells, I want the loop to end, but it doesn't
stop!
My code
Sub FormatMonths ()
With worksheets("unit forecast").range("A1:U50")
chktot=cells.find(what:="*totals*").activate
Do while chcktot=true
activecell.offset(1,0).range("a1").select
Selection.font.colorindex=3
cells.find(what:="*totals*").activate
Loop
End With
End Sub
Please help if you can.
CHristiane

---
Message posted from http://www.ExcelForum.com/