Thread: Colored Cell
View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
iKKi[_2_] iKKi[_2_] is offline
external usenet poster
 
Posts: 4
Default Colored Cell

something like this you mean

Private Sub Workbook_Open()
Dim i As Integer

For i = 1 To 4000
If Range("B" & i).Value = 0 Then
Range("A" & i).Interior.ColorIndex = 3
Else
Range("A" & i).Interior.ColorIndex = xlColorIndexNone ' whatever
End If
Next i

End Sub


regards
iKKi<<<



"brownti via OfficeKB.com" <u31540@uwe wrote in message
news:6e7ecb358ed1c@uwe...
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