Link code

  • Thread starter Thread starter Phil Hageman
  • Start date Start date
P

Phil Hageman

I would like to place code in a Module, or ThisWorkbook,
that would highlight cells with links to other places.
Something like a conditional format. It should be
something I can turn on, look at the cells, then turn off -
don't want the highlighting permanent. What code would do
this, and where would I put it?

Thanks, Phil
 
Phil,

One way:

Place this in the sheet module:


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Union(Range("a1"), Range("e1"), Range("h1")).Select
With Selection
If .Interior.ColorIndex = xlNone Then
.Interior.ColorIndex = 6
Else
.Interior.ColorIndex = xlNone
End If
End With
End Sub

Assuming that the linked cells are A1, E1, and H1 (change to your linked
cells), each time you double click on this sheet, the linked cells will turn
yellow. Double click again and they go back to no color.

Don Pistulka
 
Phil,

From the Control ToolBox put a ToggleButton on your sheet.

Click the Design Mode button to made the togglebutton work.

Add this code to the sheet module.

Private Sub ToggleButton1_Click()
Union(Range("a1"), Range("e1"), Range("h1")).Select
With Selection
If .Interior.ColorIndex = xlNone Then
.Interior.ColorIndex = 6
Else
.Interior.ColorIndex = xlNone
End If
End With
End Sub

Don Pistulka
 
Back
Top