View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Fix Code: Select Case and "Contains" selection

I would be much more inclined to use Find and FindNext than your current
method. Set a range object equal to the union of the two ranges (very sismlar
to what you have now. Format that range similar to your case else. Then do
the Find and FindNext looking at xlPart. This should be a whole pile faster
and will get around the problem with the "part of a string". Just remember
that find next will loop infinitely so you need to set up a stop that checks
to make sure that you have not come back to the original address where you
started. Also make sure that you find something in the first place using a
range object that may be set to nothing by the original find. If you need
help with the code just ask...

HTH

"Bettergains" wrote:

Hello: Here's my code. I want to look for anything that contains the
following values: "Option1" and "Option2". Sometimes it will be the single
value in the cell, somtimes it will be part of a string. I have tried
numerous syntaxes, but am coming up empty. HELP~

Dim Mark As Range

For Each Mark In Union([D6:F1200], [AF6:AF1200]).Cells

Select Case Mark.Value
Case "Option1"
Mark.Font.ColorIndex = 55
Mark.Font.Bold = True
Case "Option2"
Mark.Font.ColorIndex = 55
Mark.Font.Bold = True
Case Else
Mark.Font.Color = vbBlack
Mark.Font.Bold = False
End Select
Next