Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Conditional Formatting

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I'm trying to format a row depending on the value of a single cell within that row. Is it possible to put VB code behind the sheet to set this up. If so, can someone help me with the code. I'm trying to change the colour of the row to red when B2 = Y.

    This is the code I get when selecting formatting a single cell but when I place the code behind a sheet, it locks the cell location at B2

    Range("B2").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
    Formula1:="=""Y"""
    Selection.FormatConditions(1).Interior.ColorIndex = 4

    Hope someone can help!

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You don't actually need VBA for this-

    Select the entire row that you want to turn red. Click on Format-Conditional Formatting and change 'cell is' to 'formula is' and enter the following: -

    =$B$2="Y"

    Select your formats and that's it. HTH.

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Cheers Mudface

    Is there any easy way of copying the formula throughout column B so when a Y appears in a cell in column B, the whole row has a red fill?

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    There might be a better way of doing this, but this seems to work: -

    Select your entire sheet (click on the little grey square between the 'A' and '1' column and row nos). Click on Format- Conditional Formatting and enter: -

    =$B1="Y"

    as a formula. HTH.

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thats worked a treat, thanks mudface

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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