Add Hyperlink Using VBA Excel

seageath

Board Regular
Joined
Oct 29, 2009
Messages
102
Hi

I'm trying to add hyperlink from one sheet (Project Overhead) to another sheet (Project Sheet). Some of them are working but one of them is stuck due "type mismatch" error. Here are the code, have been trying to solve it for few hours but no luck.

Code:
' Add OH Link
Dim rngLinkSrc As Range
Dim wsTarget As String

With Worksheets("Project OH").Range("A:A")
    Set rngLinkSrc = .Find(strProject)
End With

If Not rngLinkSrc Is Nothing Then
    If rngLinkSrc.Hyperlinks.count = 0 Then
        [I]Worksheets("Project OH").Hyperlinks.Add _
        Anchor:="'Project OH'!" & rngLinkSrc.Address, _
        Address:="", _
        SubAddress:="'" & strProject & "'" & "!A1", _
        TextToDisplay:=strProject[/I]
    
        With selection
            .Name = "Calibri"
            .Font.Size = 11
            .Font.Bold = True
        End With
        Worksheets(strProject).Select
    End If
End If
' End Add Link

Appreciate if there someone out there that can give some advise.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Solved - Add Hyperlink Using VBA Excel

Done ...

I pointed to the active cell in "Project OH" and changed the code into

Code:
ActiveSheet.Hyperlinks.Add _
Anchor:=selection, _
Address:="", _
SubAddress:="'" & strProject & "'" & "!A1", _
TextToDisplay:=strProject

The problem is with the anchor value.

Now can sleep :rofl:

Thanks all.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,261
Members
452,901
Latest member
LisaGo

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