View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
steve_doc steve_doc is offline
external usenet poster
 
Posts: 140
Default changing font colour

Hi Jock
1 aproach is

using a loop through a range, assuming that your range contains no
blanks(empty)
Sub TEST_Colour()
Dim wb As Workbook
Dim ws As Worksheet
Dim rg As Range

Dim stCrit As String

Set wb = ThisWorkbook
Set ws = wb.Worksheets(1)
Set rg = ws.Range("A2")
stCrit = "PRO"

Application.ScreenUpdating = False ' increases speed on long loops

Do Until IsEmpty(rg) 'perform loop till rg is empty
If rg.Offset(0, 7) = stCrit Then 'logic comparison
rg.EntireRow.Font.Color = vbRed 'if logic is true text colour = red
Set rg = rg.Offset(1, 0) 'increase range by 1 row
Else
Set rg = rg.Offset(1, 0)
End If
Loop

Application.ScreenUpdating = True
End Sub

HTH
"Jock" wrote:

Using vba, how can I change font colour to red for the entire row (A5 - Z5)
if cell H5 contains "PRO"? And how do I then copy this code so it affects all
rows (up to 200) in the worksheet?
--
tia

Jock