Solved

How to Modify Worksheet Hyperlink Index

Posted on 2015-02-23
2
65 Views
Last Modified: 2016-02-10
The attached workbook has 13 worksheets in it.

Worksheet "Index" uses an "OnActivate" code to build hyperlinks to the other sheets.

Is there a way to have worksheets that have a property value of "xlSheetVeryHidden" NOT included in this list?

Can it be modified to create two lists: One for worksheets, one for Charts?

Regards,

Thank you to OzGrid for the start on this.
Hyperlink-Index.xlsm
0
Comment
Question by:DougDodge
2 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40625828
Hi,

pls try

Option Explicit

Private Sub Worksheet_Activate()

Dim wSheet As Worksheet
Dim chrt As Chart
Dim l As Long

l = 1

    With Me
        .Columns(1).ClearContents
        .Cells(1, 1) = "INDEX TO WORKSHEETS"
        .Cells(1, 1).Name = "Index"
    End With
    

    For Each wSheet In Worksheets
        If wSheet.Name <> Me.Name And wSheet.Visible <> xlSheetVeryHidden Then
            l = l + 1
                With wSheet
                    .Range("A1").Name = "Start_" & wSheet.Index
                    .Hyperlinks.Add Anchor:=.Range("A1"), Address:="", SubAddress:="Index", TextToDisplay:="Return to Main Worksheet"
                End With

                Me.Hyperlinks.Add Anchor:=Me.Cells(l, 1), Address:="", SubAddress:="Start_" & wSheet.Index, TextToDisplay:=wSheet.Name
        End If
    Next wSheet
l = 1
    With Me
        .Columns(2).ClearContents
        .Cells(1, 2) = "INDEX TO CHARTS"
        .Cells(1, 2).Name = "Index"
    End With
    

    For Each chrt In Charts
        If chrt.Name <> Me.Name  And chrt.Visible <> xlSheetVeryHidden  Then
            l = l + 1
                Me.Hyperlinks.Add Anchor:=Me.Cells(l, 2), Address:="", SubAddress:="Start_" & chrt.Index, TextToDisplay:=chrt.Name
        End If
    Next chrt

End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:DougDodge
ID: 40626281
Works perfectly...... Thank you once again for your assistance......
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question