Create hyperlinks by with using the link for each

jcmckeon

New Member
Joined
Nov 4, 2015
Messages
38
Office Version
  1. 365
Platform
  1. Windows
I have 200 or more hyperlinks to make to a network drive. If you do the traditional way, insert link etc, it takes WAAAAY to long. When I look at the url is it: \\str-file-01\Org Data\data\dept\Training\Employee Training Files\Balakier, Matthew\AS9100 - this was put in the traditional way it works.

But if I type exactly what's there it doesn't work. There is some "magic sauce" that I'm missing?

Ultimately I want to combine A2 B2 C2 D1 and have that appear as a clickable x See image. Whatever you can suggest would be AWESOME as I don't want to do 200+ of these.
 

Attachments

  • link.png
    link.png
    28.7 KB · Views: 11

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
This sjhould do the trick. Read the comments, and act if necessary to the ones starting with <<<<

VBA Code:
Option Explicit

Sub CreateHLink()
'

'
    Dim vIn As Variant
    Dim rOut As Range, rIn As Range
    Dim lR As Long
    Dim sURL As String
    
    Set rIn = Range("A1").CurrentArray  '<<<< Set to top left corner of your list
    
    'load list in array
    vIn = rIn.Value
    
    Set rOut = Range("D" & rIn.Cells(1, 1).Row + 1)     '<<<< column letter for hyperlink
    For lR = 2 To UBound(vIn, 1)    'skip header row
        
        'display hyperlink as 'X' but link behind is Ax & Bx & ", " & Cx & D1  (path & surname & ", " first name & & AS9100)
        rOut = "X"
        ActiveSheet.Hyperlinks.Add Anchor:=rOut, Address:=vIn(lR, 1) & vIn(lR, 2) & ", " & vIn(lR, 3) & vIn(1, 4)
    Next lR
End Sub
 
Upvote 0
This sjhould do the trick. Read the comments, and act if necessary to the ones starting with <<<<

VBA Code:
Option Explicit

Sub CreateHLink()
'

'
    Dim vIn As Variant
    Dim rOut As Range, rIn As Range
    Dim lR As Long
    Dim sURL As String
   
    Set rIn = Range("A1").CurrentArray  '<<<< Set to top left corner of your list
   
    'load list in array
    vIn = rIn.Value
   
    Set rOut = Range("D" & rIn.Cells(1, 1).Row + 1)     '<<<< column letter for hyperlink
    For lR = 2 To UBound(vIn, 1)    'skip header row
       
        'display hyperlink as 'X' but link behind is Ax & Bx & ", " & Cx & D1  (path & surname & ", " first name & & AS9100)
        rOut = "X"
        ActiveSheet.Hyperlinks.Add Anchor:=rOut, Address:=vIn(lR, 1) & vIn(lR, 2) & ", " & vIn(lR, 3) & vIn(1, 4)
    Next lR
End Sub
wow I can't wait to give this a try. So put this into a vb module? I'll let you now. Thanks again for the help.
 
Upvote 0
Yes, press Alt-F8, type a dummy name, select New... press OK. The VBA editor will open . In the window select everything, delete. Then paste the code above.
Go back to Excel, press Alt-F8 again and double click on the macro name.

Make a backup copy of your sheet first!!
 
Upvote 0
Hi Sijpie, see the images attached. I ran debug and see what's in yellow. I included a shot of the spreadsheet.
I really really appreciate your help with this.
 

Attachments

  • hyperlinkscipt1.png
    hyperlinkscipt1.png
    18.9 KB · Views: 8
  • hyperlinkscript2.png
    hyperlinkscript2.png
    63 KB · Views: 9
Upvote 0
I am away for a few days, will look at it later in the week or early next week
 
Upvote 0
Ah, costly typo...
VBA Code:
Option Explicit

Sub CreateHLink()
'

'
    Dim vIn As Variant
    Dim rOut As Range, rIn As Range
    Dim lR As Long
    Dim sURL As String
    
    Set rIn = Range("A1").CurrentRegion  '<<<< Set to top left corner of your list
    
    'load list in array
    vIn = rIn.Value
    
    Set rOut = Range("D" & rIn.Cells(1, 1).Row + 1)     '<<<< column letter for hyperlink
    For lR = 2 To UBound(vIn, 1)    'skip header row
        
        'display hyperlink as 'X' but link behind is Ax & Bx & ", " & Cx & D1  (path & surname & ", " first name & & AS9100)
        rOut = "X"
        ActiveSheet.Hyperlinks.Add Anchor:=rOut, Address:=vIn(lR, 1) & vIn(lR, 2) & ", " & vIn(lR, 3) & vIn(1, 4)
    Next lR
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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