[Solved] Excel VBA assign hyperlink to a cell


Here’s a sample of how to do that:

Sub createLink()
Dim lastRow As Integer, sheetCount As Integer, myRange As Excel.Range, c As Excel.Range
lastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
sheetCount = Application.Sheets.Count
Set myRange = Excel.ThisWorkbook.Sheets("Sheet1").Range("B1:B" & lastRow)

For Each c In myRange
    For x = 1 To sheetCount
        If Worksheets(x).Name = c.Value Then
             Excel.ThisWorkbook.Sheets("Sheet1").Hyperlinks.Add Anchor:=c, Address:="", SubAddress:=c.Value & "!A1"
        End If
    Next x
Next c
End Sub

solved Excel VBA assign hyperlink to a cell