Hyperlink multiple cells using VBA

Lockie2000

New Member
Joined
Apr 27, 2012
Messages
1
Hi,
I am trying to hyperlink about 10,000 files using VBA as. The following cells contain:
B1 = The path to the files to be linked (I named the cell range Path)
B3:B10003 = the filenames of all the pdfs (eg. Document1.pdf)

This is the code i have done but it isnt working (i am new to VBA)

Sub Macro2()
Dim FilePath, Cell, FPCell As String
FilePath = Range("Path").Value + "\"
Cell = ActiveCell.Value
FPCell = FilePath & Cell

ActiveCell.Offset(2, 1).Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Cell, Address:= _
FPCell, TextToDisplay:=Cell
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Cell, Address:= _
FPCell, TextToDisplay:=Cell

Do Until ActiveCell.Offset(0, 0).Value = ""
If ActiveCell.Offset(0, 0).Value = "" Then [A1].Select: Exit Sub
Loop
End Sub

The reason i have the path in cell B1 is because the path changes depending on which computer is being used.
Also my home computer is a 64bit but my work computer is 32bit, does this matter with the coding?
Any help would be greatly appreciated.
Thanks.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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