creating hyperlinks within a range that use a cells value as each hyperlinks name

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
458
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Whats not working with this code is that instead of using each cell's value, its using the value of the last cell in the range for every cell in the range.
(the last cell in the range is A211, and the hyperlink for every cell from A1 to A211 are all the same(?)... they all are the same value as the last cell- cell A211. How can I make it so that each cell's hyperlink is the same as that cells value?) Thanks!

VBA Code:
Private Sub CommandButton1_Click()
Dim cNam As Variant

    For Each cNam In Range(Cells(1, 1), Cells(211, 1))
        Hyperlinks.Add Range(Cells(1, 1), Cells(211, 1)), "J:\QMS_General Facility\Training\Employee_Training_Records\" & cNam.value
    Next cNam

End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Code:
Public Sub CreateHypers()
Dim cNam As Variant
    For Each cNam In Range(Cells(1, 1), Cells(211, 1))
        ActiveCell.Hyperlinks.Add cNam, "J:\QMS_General Fac1ility\Training\Employee_Training_Records\" & cNam.Value
    Next cNam
  

MsgBox "Done"
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,352
Messages
6,124,453
Members
449,161
Latest member
NHOJ

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