Hyperlink box color

L

Laurie@mtb

In Microsoft excel 2007 I have spreadsheet with hyperlinks to another page
and I would like the hyperlinked cell to be highlighted when I click on the
link. Thanks
 
T

Tom Hutchins

Do you mean you want to highlight the cell the hyperlink jumps to? Try the
following event code...

Option Explicit

Public PrevCell As Range

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
On Error Resume Next
Dim c As Range
If Target.Hyperlinks.Count > 0 Then
Set c = Range(Target.Hyperlinks(1).Range)
c.Interior.ColorIndex = 6
PrevCell.Interior.ColorIndex = xlColorIndexNone
Set PrevCell = c
End If
End Sub

I used ColorIndex 6, which is bright yellow. Change it to whatever you like.

This code needs to be pasted into the ThisWorkbook module of your workbook
in the Visual Basic Editor. If you are new to macros, this link to Jon
Peltier's site may be helpful:
http://peltiertech.com/WordPress/2008/03/09/how-to-use-someone-elses-macro/

Hope this helps,

Hutch
 

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