Thread: Colour Index
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Stefi Stefi is offline
external usenet poster
 
Posts: 2,646
Default Colour Index

You can set the background color this way
Range("B" & Target.Row).Interior.ColorIndex = Target

But in one cell (I5:I9) you can have only one ColorIndex. Setting both
foreground and background color to the same value makes the cell content
invisible.

Regards,
Stefi

€˛LiAD€¯ ezt Ć*rta:

Hi,

Sorry I should have been more specific.

I was hoping to colour the cell and the text. How do I adapt the code to do
both?

Thanks

"Stefi" wrote:

You need an event sub for that:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 5 And Target.Row <= 9 And Target.Column = 9 Then
Range("B" & Target.Row).Font.ColorIndex = Target
End If
End Sub


Regards,
Stefi

€˛LiAD€¯ ezt Ć*rta:

Hi,

Sorry yet another simple question.

I have numbers, (1,2,3 etc) in cells I5 to I9 from which I would like to
generate a colour in cells B5-9, (black, white, red etc). If I change I6
from 4 to 9 the colour in B6 updates as soon as I hit return or the down key
after entering the number.

What is the easiest way to do this?
Thanks