View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
news.microsoft.com[_8_] news.microsoft.com[_8_] is offline
external usenet poster
 
Posts: 13
Default How to apply colouring as in Cells associated with Forumla

Hello,

First thank you for your reply. I think i didnt express my question well.
Acutally i dont need to color within a cell because the cells may already
have colors that i should not modify

What i want is kind of highlight the boundary of cell or range of cells
using various (random colours) to differentiate cells or range. I dont want
to change the existing border color either. What is want is similar to what
Excel shows when you click on a cell that depends upon other cells for
example in summation, a kind of blue boundray which appears or if there are
many non continous cells it shows it in various colors.

Is this possible programmatically?

Regards
Abhilash


"Rowan" wrote in message
...
If you have no other coloured cells on the sheet (as their formatting will
be
cleared) you could try a selection change event like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Cell As Range
Dim i As Integer
Application.EnableEvents = False
Cells.Interior.ColorIndex = False
If Target.Count = 1 Then
On Error Resume Next
i = 37
For Each Cell In Target.Precedents
If i = 47 Then i = 33
Cell.Interior.ColorIndex = i
i = i + 1
Next Cell
On Error GoTo 0
End If
Application.EnableEvents = True
End Sub

Hope this helps
Rowan

In case you are unfamiliar with worksheet events right click the sheet
tab,
select view code and paste the code.


"news.microsoft.com" wrote:

hi,

When there is a sum formula applied to a cell for example

cell A5 = Cell A1 + Cell A2 + Cell A3+ Cell A4

and when we click on cell A5 each of the cells that are part of the
formula
is given various random (i think so) colours

How can i do the same programatically? My goal is not to apply formula
but
to show cells or range of cells in various kind of colours temporarily. I
am
looking for a solution where i dont have to work with cell border
colours..

Please let me know if my question is not clear.

Any pointers in this regard will be very helpful

Regards,
Abhilash