View Single Post
  #4  
Old May 21st, 2009, 02:35 PM posted to microsoft.public.excel.misc
Gary''s Student
external usenet poster
 
Posts: 7,584
Default Change cell colours using hyperlinks

Delete the old macro and replace it with:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
ActiveCell.Interior.ColorIndex = 6
ActiveCell.Offset(0, 1).Interior.ColorIndex = 6
End Sub

--
Gary''s Student - gsnu200854


"Lynda" wrote:

Thank you Gary''s Student. Your answer worked. Is it possible to modify the
code to highlight the active cell and the cell beside it as well? Thanks in
advance.
Cheers
Lynda

"Gary''s Student" wrote:

Insert the following event macro in the worksheet code area:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
ActiveCell.Interior.ColorIndex = 6
End Sub

The macro will work if the hyperlinks were Inserted rather than =HYPERLINK()

Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200854


"Lynda" wrote:

I have hyperlinks going from sheet 1 to descriptions in sheet 2. What I want
to happen is when I click on the hyperlink in sheet 1 that it will highlight
the cell in sheet 2 as yellow or some other colour. Is this possible?

Thanks in advance.
Lynda