Charting Hyperlinks

You can’t hyperlink to and from chart sheets in Excel. Or can you..?. By Liam Bastick, director with SumProduct Pty Ltd.

 

Query

I have started to use hyperlinks in my spreadsheets as a way of navigating around the workbook. However, I cannot create hyperlinks either to or from chart sheets. Any ideas?

 

Advice

Regular readers of these articles will have noted that I commonly use hyperlinks in my Excel files as they are a great way to move around a file. Once you know how to construct them, they take seconds to insert.

The ‘Insert Hyperlink’ dialog box is fairly straightforward to use and readily accessed via one of two keyboard shortcuts, either ALT + I + I or CTRL + K. Alternatively:

 

Excel 2003 and earlier Excel 2007
  • From Insert drop down menu, select Hyperlink
  • From the Ribbon, select the Insert tab and click on the Links group

 

To create a hyperlink, first select the cell or range of cells that you wish to act as the hyperlink (i.e. clicking on any of these cells will activate the hyperlink). Then, open the Insert Hyperlink dialog box (above) and select ‘Place in This Document’ as the ‘Link to:’, which will change the appearance of the rest of the dialog box.

Insert the text for the hyperlink in the ‘Text to display:’ input box (clicking on the ‘ScreenTip…’ macro button will allow you to create an informative message in a message box when you hover over the hyperlink).

The next two input boxes, ‘Type the cell reference:’ and ‘Or select a place in this document:’, work in tandem – sort of:

So what is the problem in the case of our query? Simple: Excel will not let you link to chart sheets and range names cannot be attached to chart sheets – hence, seemingly no way to link to the worksheet. Most model developers will circumvent this issue by embedding their charts in Excel spreadsheets and then it’s easy. But what if you don’t want to do this for some reason (e.g. some Management Information Systems require charts to be on their own worksheets)?

There is an Excel function, HYPERLINK(link_location,[friendly_name]), but this does not help us either as there is no cell on a chart sheet to link to. There is a neat workaround, however…

 

Linking to a Chart Sheet

Add a new worksheet in the workbook, and then create a new hyperlink as follows:

This final step activates Excel’s Visual Basic Editor. The following code should be copied into the Module area of the screen (the large white area usually located on the right hand side):

 

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    If Target.TextToDisplay = "Critical Text 01" Then Sheets("Critical Text 02").Select
End Sub

 

[Critical Text 01 and Critical Text 02 should be replaced with the relevant text.]

With the hyperlink dead, clicking on a cell containing a hyperlink will merely test for the required text; if found, it will jump to the chart sheet as requested.

 

Linking from a Chart Sheet

The problem with chart sheets is that there is no cell to attach a hyperlink to, so we need to get more inventive:

The attached Excel file should make things clearer.

 

If you have a query for this section, please feel free to drop Liam a line at liam.bastick@sumproduct.com or visit the website www.sumproduct.com