Hello BrI,
A Collection object stores key/item pairs. The key is a string used to reference the item stored under the key. An example of this is Worksheets. Each Worksheet has a name (the key) and the Worksheet Object (the item associated with the key). While key must be a string, the item can be any number, string, or object except a User Defined Data Type.
I am not exactly sure how you have your Hyperlinks setup, but I will use a real Hyperlink example for this Collection. For this example we will assume there are real web hyperlinks in column "A". These hyperlinks must be pasted in or automatically converted when type in by Excel. This will not work with Hyperlinks created by Formulas.
PLace Code in VBA Module
' Making this Public in Module makes the Collection available to all code in your VBA Project.
Public myColl As Collection
Sub LoadCollection()
Dim Cell As Range
Dim Rng As Range
' Check if the Collection object is instantiated.
If myColl Is Nothing Then
Set myColl = New Collection
End If
Set Rng = Range("A1", Cells(Rows.Count, "A").End(xlUp))
For Each Cell In Rng
' If a key already exists then an error occurs. Ignore the error.
' Key names ignore case.
On Error Resume Next
If Cell.HyperLinks.Count > 0 Then
myColl.Add Cell.Hyperlinks(1), Cell.Text
End If
On Error GoTo 0
Next Cell
End Sub
Let's assume in cell "A1", you type "www.google.com". Excel will convert this to a hyperlink. When you access a member of the Collection by it's key name, in this "www.google.com", the Hyperlink object is returned. You now have full access to all properties and methods associated with this object.
Sub Test()
Dim Hlnk As Object
' Assign the hyperlink for the key to an object variable
Set Hlnk = myColl("www.google.com")
' Open the web page in the browser.
Hlnk.Follow
End Sub