Conditional Fomatting (>3 conditions)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tiwariprakash
    New Member
    • Jul 2007
    • 6

    Conditional Fomatting (>3 conditions)

    Hi
    I am trying to change the colour of cells based on the values of 2 other cells but I couldn't get the right VBA code for Excel 2003. Could you please help me with the following conditions:

    if valueX<=2 and valueY<=2, green colour

    if valueX>=4 and valueY>=4, red colour

    otherwise, yellow colour.

    There might be more similar conditions, therefore I want to use VB to handle more than 3 conditions.

    Many thanks

    Prakash
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    #2
    Originally posted by tiwariprakash
    Hi
    I am trying to change the colour of cells based on the values of 2 other cells but I couldn't get the right VBA code for Excel 2003. Could you please help me with the following conditions:

    if valueX<=2 and valueY<=2, green colour

    if valueX>=4 and valueY>=4, red colour

    otherwise, yellow colour.

    There might be more similar conditions, therefore I want to use VB to handle more than 3 conditions.

    Many thanks

    Prakash
    TRy using
    [CODE=vb]Dim num as cell.val
    Select Case num
    Case num>2
    Cell.color = red
    Case num >3
    Cell.Color = blue
    end select
    Etc[/CODE]

    Comment

    Working...