jwbrouse01
New Member
- Joined
- Jun 2, 2022
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
Greetings!
I am trying to use hyperlinks to run a macro which opens a userform. I previously found and adapted the below code to create the hyperlinks
When I try to click on the hyperlinks, I get an error message "Reference isn't valid" and the rest of the function does not run. I do apologize if this has already been solved elsewhere, but all my searches have brought up that it is critical to add the "Set MyUDF = Selection", otherwise you will get the aforementioned error.
Can someone please assist me? Thanks!
I am trying to use hyperlinks to run a macro which opens a userform. I previously found and adapted the below code to create the hyperlinks
VBA Code:
Sub CreateHyperlinks()
With ActiveSheet
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
End With
Range(Cells(2, 6), Cells(LastRow, 6)).Formula = "=HYPERLINK(""#MyUDF()"", ""Sign Up..."")"
End Sub
Function MyUDF()
Set MyUDF = Selection 'This is required for the link to work properly
MsgBox "The clicked cell address is " & Selection.row
End Function
When I try to click on the hyperlinks, I get an error message "Reference isn't valid" and the rest of the function does not run. I do apologize if this has already been solved elsewhere, but all my searches have brought up that it is critical to add the "Set MyUDF = Selection", otherwise you will get the aforementioned error.
Can someone please assist me? Thanks!