Create hyperlinks by with using the link for each

jcmckeon

New Member
Joined
Nov 4, 2015
Messages
34
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: 9

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

sijpie

Well-known Member
Joined
Nov 1, 2008
Messages
4,005
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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
 

jcmckeon

New Member
Joined
Nov 4, 2015
Messages
34
Office Version
  1. 365
Platform
  1. Windows
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.
 

sijpie

Well-known Member
Joined
Nov 1, 2008
Messages
4,005
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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!!
 

jcmckeon

New Member
Joined
Nov 4, 2015
Messages
34
Office Version
  1. 365
Platform
  1. Windows
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: 7
  • hyperlinkscript2.png
    hyperlinkscript2.png
    63 KB · Views: 7

sijpie

Well-known Member
Joined
Nov 1, 2008
Messages
4,005
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am away for a few days, will look at it later in the week or early next week
 

sijpie

Well-known Member
Joined
Nov 1, 2008
Messages
4,005
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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
 
Solution

jcmckeon

New Member
Joined
Nov 4, 2015
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Thank you so much. I really appreciate your help. Be well!
 

Forum statistics

Threads
1,175,487
Messages
5,897,690
Members
434,673
Latest member
kktfc

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
Top