View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Conditional Formatting with VBA

Maybe this

Right click your sheet tab, view code and paste it in

Sub stantial()
lastrow = Cells(Cells.Rows.Count, "D").End(xlUp).Row
Set myrange = Range("D1:D" & lastrow)
For Each C In myrange
If UCase(C.Value) = "HOURS" Then
For x = 5 To 36
If Cells(C.Row, x).Value = 9 Then
Cells(C.Row, x).Interior.ColorIndex = 3
End If
Next
End If
Next
End Sub

Mike

"Francois via OfficeKB.com" wrote:

I though this would be easy, but I can't get it right, any help would be
greatly appreciated.

I'm trying to go down Column "D" (about 250 rows) and when the contents of a
cell = "HOURS" go to each cell to the right (31 cells) and if the contents of
that cell = 9 then colour(color) the font red.
Then continue down Col "D" and so on.

I can get the Macro to get to the cell containing "HOURS", but after that
nothing works, so I'm stumped.

Eventually I will have many more conditions that just the one above, so I
can't use Conditional Formatting, and in fact I don't want to.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200805/1