We help IT Professionals succeed at work.
Get Started

Cell shading depending on value 2 cells below in a row.

Nick Denny
Nick Denny asked
on
944 Views
Last Modified: 2011-09-20
Hi Experts
I am using this code:


Sub ColourNonOrder()
    Dim rng As Range, cell As Range
    Set rng = Range("C1:AO1")
    For Each cell In rng
    If cell.Offset(0, 2).Value = "#N/A"  Then
       cell.Interior.Color = vbGreen
    Else
       cell.Interior.Color = xlAutomatic
    End If
  Next
End Sub


to try and do the following:

Look at row 3
(in row 3 there is a IF,ISNA,Lookup and I'm trying to return a green shading (in Row 1) above any cell that has nothing returned).
Instead - I'm getting all of row 1 from C to AO changing to green.

How can I adapt this please?
Ultimately I am trying to add a macro button to turn on or off cell shading in row 1.

Many thanks

Nick.
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE