ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cell color macro doesn't work (https://www.excelbanter.com/excel-programming/354850-cell-color-macro-doesnt-work.html)

Darren

cell color macro doesn't work
 
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



Carim[_3_]

cell color macro doesn't work
 

Hello Darren,

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

HTH
Cheers
Carim


Darren

cell color macro doesn't work
 
Wow,

Amazingly simple, Thanks for the help.

-Darren

"Carim" wrote:


Hello Darren,

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

HTH
Cheers
Carim




All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com