View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NateBuckley NateBuckley is offline
external usenet poster
 
Posts: 146
Default Conditional Formatting with VBA

Here you go, something I just knocked up, hopefully it'll work

Public Sub TimmysTool()
Dim j As Long
Dim i As Long
Dim colSize As Long
Dim rowLength As Long

colSize = Sheets("Sheet1").Cells(Rows.Count, 4).End(xlUp).Row

For i = 1 To colSize
If Sheets("Sheet1").Cells(i, 4).Value = "HOURS" Then
rowLength = Sheets("Sheet1").Cells(i,
Columns.Count).End(xlToLeft).Column
j = 4
While j <= rowLength
If Sheets("Sheet1").Cells(i, j).Value = 9 Then
With Sheets("Sheet1").Cells(i, j)
.Font.Color = RGB(255, 0, 0)
End With
End If
j = j + 1
Wend
End If
Next i
End Sub

"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