View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Kevin B Kevin B is offline
external usenet poster
 
Posts: 1,316
Default Change cells color & cells contains if formula

Perhaps this little code snippet will point you in the right direction:

Sub FormulaCellColor()

Dim varVal As Variant
Dim strCell As String
Dim r As Range

Range("A1").Select
varVal = ActiveCell.Value

Do Until varVal = ""
Set r = ActiveCell
If r.HasFormula Then
With r
.Interior.Color = vbBlue
.Font.Color = vbWhite
End With
End If
ActiveCell.Offset(1).Select
Loop

Set r = Nothing

End Sub


--
Kevin Backmann


"dot" wrote:

I'm new to excel vba. I'm tried out the vba code for changing cells
color but it don't work if my cells contains a if formula (eg. all
cells in cloumn A contain =if(and(b1="Rej",c1="Rej"),"Rej",....). Any
idea what should be the code?