Link code

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
 
D

Don P

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
 
D

Don P

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top