cell color macro doesn't work

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this macro that I have been trying to use to change the cell colors of
the cells when the value inside it changes.

Private Sub Worksheet_change(ByVal Target As Range)
If Not Application.Intersect(Range("G4:G17"), Target) Is Nothing Then
If Target.Value > 0 Then
Target.Cells.Interior.ColorIndex = 35
ElseIf Target.Value < 0 Then
Target.Cells.Interior.ColorIndex = 38
Else
Target.Cells.Interior.ColorIndex = xlNone
End If
End If
End Sub

I can't understand why it wouldn't work. The only things that I can think
might be affecting it is: 1, the cells are linked to other cells in the sheet
which are linked to an outside program. 2, I don't know if this code
translates to each individual cell color changing as the value changes or if
it wants to change the range when a cell changes . . . anyway, thanks for
any help you can give me.

-DMS
 
Hello Darren,

It seems that you should not bother with an event macro ... since
conditional formatting could easily do the job ...

HTH
Cheers
Carim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top