Thread: Colored Cell
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
brownti via OfficeKB.com brownti via OfficeKB.com is offline
external usenet poster
 
Posts: 103
Default Colored Cell

That doesnt work for me. I dont understand. I feel like i a loop would be
easier, i just cant get it to work. It only has two different conditions it
needs. If B1=0, A1 should be red, if B1 doesnt equal 0, go to next row.


Ron de Bruin wrote:
Then we do it like this

I use the whole column here but you can change it to
If Not Application.Intersect(Range("B1:B4000"), Target) Is Nothing Then

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("B:B"), Target) Is Nothing Then
Select Case Target.Value
Case 0: Target.Offset(0, -1).Interior.ColorIndex = 3
Case 1: Target.Offset(0, -1).Interior.ColorIndex = 5
Case 2: Target.Offset(0, -1).Interior.ColorIndex = 7
Case 3: Target.Offset(0, -1).Interior.ColorIndex = 9
Case 4: Target.Offset(0, -1).Interior.ColorIndex = 11
Case 5: Target.Offset(0, -1).Interior.ColorIndex = 13
Case Else: Target.Offset(0, -1).Interior.ColorIndex = xlColorIndexNone
End Select
End If
End Sub

I dont think I was totally clear. It more like if B1 = 0 then A1 is red, if
b2 = 0 then A1 is red etc...through 4000 rows. i think i need a loop that

[quoted text clipped - 20 lines]
consecutive cells. Probably be easiest if it just happens when the workbook
is opened. Thanks in advance for any help.


--
Message posted via http://www.officekb.com