add hyperlinks to a range

hocs

New Member
Joined
Nov 13, 2009
Messages
33
Hi,
i need code to add hyperlink to a range, says D4:D53, to refer to sheet 4 to sheet 53.
Note: sheets name will change but i want the link to always refer to sheet 4 to sheet 53. i.e. valid links irregards to sheets names.

Thanks!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi,
i need code to add hyperlink to a range, says D4:D53, to refer to sheet 4 to sheet 53.
Note: sheets name will change but i want the link to always refer to sheet 4 to sheet 53. i.e. valid links irregards to sheets names.

Thanks!

i have got code which is close to what i want but need some modification:

Sub InsertHyperlinks()
Application.ScreenUpdating = False
Dim ws As Worksheet, _
shtName As String, _
nrow As Long, _

nrow = 0

For Each ws In ActiveWorkbook.Worksheets (i only want it to start from sheet 4 to the last sheet)
nrow = nrow + 1
With ws
shtName = ws.Name
With Sheets("INVOICE SUMMARY")
.Range("D" & nrow).Hyperlinks.Add _
Anchor:=Sheets("INVOICE SUMMARY").Range("D" & nrow), Address:="#'" & _
shtName & "'!A1", TextToDisplay:=shtName
End With
End With
Next ws

End Sub

This will insert hyperlinks for all sheets into sheet "INVOCIE SUMMARY" start from D1. However i want to ignore the 1st 3 sheets i.e. to start insert hyperlink for sheet 4 into cell D4 of INVOICE SUMMARY until the last worksheets.
Please advise.
Thanks!
 
Upvote 0
Try

Code:
Sub InsertHyperlinks()
Application.ScreenUpdating = False
Dim ws As Worksheet, shtName As String, nrow As Long, i As Integer
nrow = 0
For i = 4 To ActiveWorkbook.Sheets.Count
    Set ws = ActiveWorkbook.Sheets(i)
    nrow = nrow + 1
    With ws
        shtName = ws.Name
        With Sheets("INVOICE SUMMARY")
            .Range("D" & nrow).Hyperlinks.Add _
                Anchor:=Sheets("INVOICE SUMMARY").Range("D" & nrow), Address:="#'" & _
                shtName & "'!A1", TextToDisplay:=shtName
        End With
    End With
Next i
End Sub
 
Upvote 0
Great! Thanks VoG!
nrow=3 will get what i want! (link starts from D4 onwards!)

Cheers!
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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