On Fri, 21 May 2010 04:38:01 -0700, Cell Calculation <Cell
I have a cell with a calculation in it. I want to hightlight the cells that
are included in the calculation.
If this is just something you will do once or twice, you can use the Trace
Precedents. Its on the Formula Ribbon in Excel 2007; and someplace else in
earlier versions.
If it's something you want to do differently, you could use a VBA macro to do
this.
Do you want to highlight the cells that are directly referenced in your target
cell? or those that are indirectly referenced also (e.g. if one of the
precedents has a formula also?).
If the latter, change "directprecedents" below to just "precedents".
To enter this event-triggered Macro, right click on the sheet tab.
Select "View Code" from the right-click drop-down menu.
Then paste the code below into the window that opens.
Now, whenever you select a cell, the direct precedents will be highlighted in
Green. If you have different color formatting of those cells you need to
restore, you will need to save that, too.
If you want different functionality, you will have to be more specific.
====================================
Option Explicit
Dim LastTarget As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range
Application.EnableEvents = False
If Not LastTarget Is Nothing Then
For Each c In LastTarget
c.Interior.ColorIndex = xlNone
Next c
End If
On Error Resume Next
For Each c In Target.DirectPrecedents
c.Interior.Color = vbGreen
Next c
Set LastTarget = Target.DirectPrecedents
On Error GoTo 0
Application.EnableEvents = True
End Sub
==================================
--ron