+ Reply to Thread
Results 1 to 2 of 2

Conditional format macro

  1. #1
    Elaine
    Guest

    Conditional format macro

    I have 20 columns in an Excel 2003 spreadsheet. I am not sure how many rows
    there are as this could change.

    If Column D and Column E are NOT equal, I would like both the cells
    (colorIndex to be 40) to be tan

    If Column F and Column G are not equal then I would like to shade the cells
    tan as above.

    Similarly for Columns H and I.

    The last row has the word Grand Total in Col A and that the conditional
    formatting should not apply to that row.

    I know how to do this with conditional formatting but could someone please
    help me do this with a macro that I can install on my PC? I have to implement
    this formatting for several spreadsheets of various sizes and a macro would
    be much easier to use.

    Thanks.

  2. #2
    Bob Phillips
    Guest

    Re: Conditional format macro

    Sub AddCF()
    Dim iLastRow As Long

    iLastRow = Cells(Rows.Count, "A").End(xlUp).Row - 1
    With Range("D1").Resize(iLastRow, 2)

    .FormatConditions.Delete
    .FormatConditions.Add Type:=xlExpression, _
    Formula1:="=$D" & ActiveCell.Row & _
    "<>$E" & ActiveCell.Row
    .FormatConditions(1).Interior.ColorIndex = 40
    End With

    End Sub


    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Elaine" <[email protected]> wrote in message
    news:[email protected]...
    > I have 20 columns in an Excel 2003 spreadsheet. I am not sure how many

    rows
    > there are as this could change.
    >
    > If Column D and Column E are NOT equal, I would like both the cells
    > (colorIndex to be 40) to be tan
    >
    > If Column F and Column G are not equal then I would like to shade the

    cells
    > tan as above.
    >
    > Similarly for Columns H and I.
    >
    > The last row has the word Grand Total in Col A and that the conditional
    > formatting should not apply to that row.
    >
    > I know how to do this with conditional formatting but could someone please
    > help me do this with a macro that I can install on my PC? I have to

    implement
    > this formatting for several spreadsheets of various sizes and a macro

    would
    > be much easier to use.
    >
    > Thanks.




+ 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