hyperlink object challenge

viggen66

New Member
Joined
Jan 30, 2013
Messages
42
Dear Users,

I have done this macro to make hyperlinks to sheets, which have color tabs different from the default ones, but I have solved this with the confusing activecell.hyperlink formula =" and written bellow.


Code:
Dim ws2 As Long

    For ws2 = 1 To ActiveWorkbook.Worksheets.Count

    If Worksheets(ws2).Tab.ColorIndex <> xlColorIndexNone Then

    ws3 = Sheets(ws2).Name

    ActiveCell.Offset(1, 0).Range("A1").Select

    ActiveCell.Formula = "=HYPERLINK(""#""&CELL(""address"",'" & ws3 & "'!A1)," _
          & """" & ws3 & """)"


End If


Next ws2

Moreover, looking into the hyperlink object, how could I rewrite the hyperlink macro without using the formula way? Is there anyone here expert on this object?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi viggen66,

I don't know much about hyperlinks, but recording a bit helped quite a lot, from the recording I got:

.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="gas!A1", TextToDisplay:="BLA"

Transforming your code with that example, that would lead to:

Code:
    Dim ws2 As Long
    ResRw = 1
    Set IndexSht = Worksheets("IndexSheet")
    For ws2 = 1 To ActiveWorkbook.Worksheets.Count
        If Worksheets(ws2).Tab.ColorIndex <> xlColorIndexNone Then
            ws3 = Sheets(ws2).Name
            IndexSht.Range("A" & ResRw).Hyperlinks.Add Anchor:=IndexSht.Range("A" & ResRw), Address:="", SubAddress:=ws3 & "!A1", TextToDisplay:=ws3
            ResRw = ResRw + 1
        End If
    Next ws2

Cheers,

Koen
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,101
Members
448,548
Latest member
harryls

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