M
Mo2
ok, thanks to this here site:
http://www.ozgrid.com/VBA/excel-conditional-formatting-limit.htm
and help from u guys, i've figured out how to shade cells based on conditions.
(I couldnt use Conditional Format becuz there was more than 3 conditions)
anyhow...
this piece of code works as it should.
when a cell value is "1", its an orange color
when a cell value is less than 0, the cell turns red.
my problem is... this code doesnt apply to cells that already have "1" as a
value, and so forth (the other cases mentioned below)
why doesn't it ? and how i would i make it?
also (if it isn't resolved by the first questions resolve)
it gives me an error when i change a cell's value a 2nd or 3rd time
(i.e. from value "-3" (cell color turns red) to "4" (gives an error)
error also occurs when i delete a cell or paste something over multiple cells.
here's my code..... thanks in advance if you can help me out
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A25344")) Is Nothing Then
Select Case Target
Case Is < 0
icolor = 3
Case 0
icolor = 51
Case 1
icolor = 45
Case 2
icolor = 4
Case 3
icolor = 10
Case 4
icolor = 5
Case 5
icolor = 48
Case 6
icolor = 9
Case Is > 6
icolor = 3
Case Else
icolor = 2
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub
http://www.ozgrid.com/VBA/excel-conditional-formatting-limit.htm
and help from u guys, i've figured out how to shade cells based on conditions.
(I couldnt use Conditional Format becuz there was more than 3 conditions)
anyhow...
this piece of code works as it should.
when a cell value is "1", its an orange color
when a cell value is less than 0, the cell turns red.
my problem is... this code doesnt apply to cells that already have "1" as a
value, and so forth (the other cases mentioned below)
why doesn't it ? and how i would i make it?
also (if it isn't resolved by the first questions resolve)
it gives me an error when i change a cell's value a 2nd or 3rd time
(i.e. from value "-3" (cell color turns red) to "4" (gives an error)
error also occurs when i delete a cell or paste something over multiple cells.
here's my code..... thanks in advance if you can help me out
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A25344")) Is Nothing Then
Select Case Target
Case Is < 0
icolor = 3
Case 0
icolor = 51
Case 1
icolor = 45
Case 2
icolor = 4
Case 3
icolor = 10
Case 4
icolor = 5
Case 5
icolor = 48
Case 6
icolor = 9
Case Is > 6
icolor = 3
Case Else
icolor = 2
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub