Hyperlink exceet maximum characters - Modify sub

orjanmen

New Member
Joined
May 21, 2014
Messages
27
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am creating mailto:-links that are way to long, so they return "#Value" if I use =HYPERLINK().

I Have found this Sub, but I'm not experienced enough to modify it.

Code:
Sub HyperlinkMaker()
'Code assumes column A and B values will be concatenated and used to make a hyperlink
'The hyperlink will be put in column C
Dim i As Long, firstRow As Long, lastRow As Long
Dim sFriendly As String, sHyperlink As String
firstRow = 2        'Put first hyperlink on this row
With ActiveSheet
    lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row     'Look at last cell in column A with data
    For i = firstRow To lastRow
        sHyperlink = .Cells(i, "A").Value & .Cells(i, "B").Value    'Build the hyperlink
        sFriendly = .Cells(i, "B").Value                            'Display the "Friendly" value instead of full hyperlink
        If sHyperlink <> "" Then .Hyperlinks.Add anchor:=.Cells(2, 3), Address:=sHyperlink, TextToDisplay:=sFriendly
    Next
End With
End Sub

This is what I want to modify:

  1. Only run on 'Sheet1'.
  2. Continue to next row (now it only run on row 2.)
  3. Stop if cell in same row in 'Sheet2' is blank

Greatly appreciate your help
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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