Results 1 to 8 of 8

How to conditionally format cells either side of the target cell?

Threaded View

bralew How to conditionally format... 12-15-2016, 11:05 AM
xlnitwit Re: How to conditionally... 12-15-2016, 11:29 AM
bralew Re: How to conditionally... 12-15-2016, 11:44 AM
bralew Re: How to conditionally... 12-15-2016, 11:40 AM
xlnitwit Re: How to conditionally... 12-15-2016, 11:55 AM
bralew Re: How to conditionally... 12-16-2016, 04:41 AM
xlnitwit Re: How to conditionally... 12-16-2016, 05:22 AM
bralew Re: How to conditionally... 12-16-2016, 05:30 AM
  1. #1
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    How to conditionally format cells either side of the target cell?

    Hi All,

    I received some excellent code from Xlnitwit which I've edited to involve 2 colours when formatting. However, I would like to edit further
    so that, rather than selecting specific ranges for formatting, I would like to affect 5 cells to the left (B5:F5) and one cell to the right (H5).

    As I'm sure you can see, the cell changes green when "COMP" is added and red when "INCOMP" is added. Here's the code:

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("G5")) Is Nothing Then
        
        
            If Range("G5").Value2 = "COMP" Then
                Range("B5:I5").Interior.Color = vbGreen
                End If
                
            If Range("G5").Value2 = "INCOMP" Then
                Range("B5:I5").Interior.Color = vbRed
                End If
                
                If Range("G5").Value2 = "" Then
                Range("B5:I5").Interior.Color = xlColorIndexNone
                End If
            
            Else
                Range("B5:I5").Interior.ColorIndex = xlColorIndexNone
            End If
            
            
           
            
            
    
    End Sub
    Last edited by bralew; 12-15-2016 at 11:12 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 01-20-2016, 08:56 AM
  2. Replies: 1
    Last Post: 07-03-2014, 06:33 AM
  3. Using COUNTIF to Conditionally Format Cells
    By brreaves in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-05-2014, 12:33 AM
  4. [SOLVED] Issue with side-by-side column graph format
    By Sam Capricci in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-15-2013, 07:01 AM
  5. Replies: 6
    Last Post: 02-16-2013, 05:12 AM
  6. [SOLVED] How can I conditionally format cells that contain formulas?
    By jhofmann in forum Excel General
    Replies: 2
    Last Post: 04-06-2006, 11:10 AM
  7. [SOLVED] conditionally format cells
    By elad in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-13-2005, 01:06 PM

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