Hyperlink

Harikrushna

New Member
Joined
Oct 31, 2014
Messages
18
I am having workbook containing number of worksheets say around 200. in summary sheet ( sheet no. 1 ) , I have list of name of all worksheet having hyperlink to particular sheet. now i want to change hypelink all together . any formula or any VBA code available ?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
i have remove some rows from the list of worksheet and also remove worksheet of that name . due to which in subsequent row of removed row , hyperlink remove automatically and in other rows hyperlink changed. so i want to make it proper.
 
Upvote 0
by utilising VB code running it, i am getting error -5 i.e. invalid procedure code or argument . please give solution
 
Upvote 0
Is this the code you are using and can you tell us which line is highlighted when you receive the error?

Rich (BB code):
Sub CreateTOC()
    '   Code by Zack Baresse
    If ActiveWorkbook Is Nothing Then
        MsgBox "You must have a workbook open first!", vbInformation, "No Open Book"
        Exit Sub
    End If
    
    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
    
        Dim WS As Worksheet, _
            ct As Chart, _
            shtName As String, _
            nrow As Long, _
            tmpCount As Long, _
            i As Long, _
            numCharts As Long
        
        nrow = 3
        i = 1
        numCharts = ActiveWorkbook.Charts.Count
        
        On Error GoTo hasSheet
        Sheets("Table of Contents").Activate
        If MsgBox("You already have a Table of Contents page.  Would you like to overwrite it?", _
        vbYesNo + vbQuestion, "Replace TOC page?") = vbYes Then GoTo createNew
        Exit Sub

hasSheet:
    Sheets.Add before:=Sheets(1)
    GoTo hasNew

createNew:
    Sheets("Table of Contents").Delete
    GoTo hasSheet

hasNew:
    tmpCount = ActiveWorkbook.Charts.Count
    If tmpCount > 0 Then tmpCount = 1
        ActiveSheet.Name = "Table of Contents"
        
        With Sheets("Table of Contents")
            '.Cells.Interior.ColorIndex = 4
                With .Range("B2")
                    .Value = "Table of Contents"
                    .Font.Bold = True
                    .Font.Name = "Calibri"
                    .Font.Size = "24"
                End With
        End With
        
        For Each WS In ActiveWorkbook.Worksheets
            nrow = nrow + 1
            With WS
                shtName = WS.Name
                With Sheets("Table of Contents")
                    .Range("B" & nrow).Value = nrow - 3
                    .Range("C" & nrow).Hyperlinks.Add _
                        Anchor:=Sheets("Table of Contents").Range("C" & nrow), Address:="#'" & _
                        shtName & "'!A1", TextToDisplay:=shtName
                    .Range("C" & nrow).HorizontalAlignment = xlLeft
                End With
            End With
        Next WS
        
        If numCharts <> 0 Then
            For Each ct In ActiveWorkbook.Charts
                nrow = nrow + 1
                shtName = ct.Name
                With Sheets("Table of Contents")
                    .Range("B" & nrow).Value = nrow - 3
                    .Range("C" & nrow).Value = shtName
                    .Range("C" & nrow).HorizontalAlignment = xlLeft
                End With
            Next ct
        End If
        
        With Sheets("Table of Contents")
            With .Range("B2:G2")
                .MergeCells = True
                .HorizontalAlignment = xlLeft
            End With
        
            With .Range("C:C")
                .EntireColumn.AutoFit
                .Activate
            End With
            .Range("B4").Select
        End With
    
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With
    
    MsgBox "Done!" & vbNewLine & vbNewLine & "Please note: " & _
        "Charts are listed after regular " & vbCrLf & _
        "worksheets and will not have hyperlinks.", vbInformation, "Complete!"

End Sub

 
Upvote 0
by using above code i am getting TOC in another sheet . i want to change only hyperlink for Eg.
Sheet name
1poi
2dafg

<tbody>
</tbody>

above given are the sheet name 1, 2 in my list, name given in list is poi, dafg - hyperlink is given to name. i want to change link without changing name
 
Upvote 0
If you do a find and replace for "Table of Contents" and replace with the name of your sheet that contains your hyperlinks do you get what you need?

**Test on a copy of your workbook**
 
Upvote 0
i am getting run time error 1004 i.e. application defined or object defined error. please help.

that original sheet is not available now.
 
Last edited:
Upvote 0
What do you want the "table of contents" sheet to be called?
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top