+ Reply to Thread
Results 1 to 2 of 2

Change cells color & cells contains if formula

  1. #1
    dot
    Guest

    Change cells color & cells contains if formula

    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?


  2. #2
    Kevin B
    Guest

    RE: 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?
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1