Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Highlight the cells referenced in the active cell formula

I want to have the cells that are referenced in the active cells formula
highlight. For example if I have column A cell 1 with a formula of
=sum(b2+c3+g6) I would like for the cells b2, c3, g6 to highlight yellow. The
formula changes for each cell as do the referenced cells. Does anyone know if
this is possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Highlight the cells referenced in the active cell formula

If you want to give up Undo, colored cells, and the ability to paste on the
sheet, in the selectonchange event, you could write code to uncolor all
cells, then use the Target(1).DirectPrecedents to color the cells.

Demoing directprecedents from the immediate window.

? activecell.Formula
=SUM(B2+C3+G6)
? activecell.DirectPrecedents.Address
$B$2,$C$3,$G$6

--
Regards,
Tom Ogilvy


"Charles" wrote:

I want to have the cells that are referenced in the active cells formula
highlight. For example if I have column A cell 1 with a formula of
=sum(b2+c3+g6) I would like for the cells b2, c3, g6 to highlight yellow. The
formula changes for each cell as do the referenced cells. Does anyone know if
this is possible?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Highlight the cells referenced in the active cell formula

Thanks for the suggestion. I tried the code below,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A1", "IV65536").Interior.ColorIndex = xlNone
If Range(ActiveCell.Address(RowAbsolute:=False,
COLUMNABSOLUTE:=False)).Formula Like "=*" Then

Range(ActiveCell.Address(RowAbsolute:=False,
COLUMNABSOLUTE:=False)).DirectPrecedents.Select

With Target.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
End Sub

I'm not sure if that is what you had in mind or if there is a cleaner way to
do this process. I would also like to have the starting cell be the active
cell after the highlights are done. Any ideas/suggestions would be great!



"Tom Ogilvy" wrote:

If you want to give up Undo, colored cells, and the ability to paste on the
sheet, in the selectonchange event, you could write code to uncolor all
cells, then use the Target(1).DirectPrecedents to color the cells.

Demoing directprecedents from the immediate window.

? activecell.Formula
=SUM(B2+C3+G6)
? activecell.DirectPrecedents.Address
$B$2,$C$3,$G$6

--
Regards,
Tom Ogilvy


"Charles" wrote:

I want to have the cells that are referenced in the active cells formula
highlight. For example if I have column A cell 1 with a formula of
=sum(b2+c3+g6) I would like for the cells b2, c3, g6 to highlight yellow. The
formula changes for each cell as do the referenced cells. Does anyone know if
this is possible?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row select mode to highlight active row of active cell Bart Fay[_2_] Excel Discussion (Misc queries) 0 May 11th 10 09:34 PM
Trying to highlight cells that have the same value as the active c Excel_Rookie Excel Worksheet Functions 9 June 12th 09 02:45 AM
Highlight Cell Based Upon Referenced Cell Data Tee Excel Worksheet Functions 3 September 12th 08 05:26 PM
How to highlight cells referenced by other cells Jude Reason Excel Worksheet Functions 1 December 10th 06 10:46 AM
Click in cell w/ formula and get colors in referenced cells albean Excel Discussion (Misc queries) 0 November 11th 05 07:04 PM


All times are GMT +1. The time now is 07:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"