+ Reply to Thread
Results 1 to 6 of 6

Coloring 3 cells based on condition in 1

  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Coloring 3 cells based on condition in 1

    Hi

    im trying to get a code for 3 different scenarios

    Range will be something like A4:K4
    For each cell in range

    1. If cell value < 0, then color that cell and the two cells below it
    2. If cell value = 0, then color that cell, the one above, and the one below
    3. If cell value > 0 , color that cell, and the two cells above it

    these will be in separate macros so dont worry about which scenario takes precedence,

    If cell.value = 0 Then
    cell.interior.colorindex = 9

    'now what do i do, i need to color 2 more cells...

    thanks

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Coloring 3 cells based on condition in 1

    Here is one way:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Coloring 3 cells based on condition in 1

    TWhy not just use Conditional Formatting

    http://www.excel-it.com/excel_condit...formatting.htm
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Re: Coloring 3 cells based on condition in 1

    Thanks Stephen, nicely done.

  5. #5
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Re: Coloring 3 cells based on condition in 1

    thats a very useful link there Roy, cheers!

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Coloring 3 cells based on condition in 1

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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