Answers for "excel formula hyperlink to run vba code"

VBA
22

excel Running VBA from a HYPERLINK()

'Execute VBA code from hyperlink on a worksheet that is the result 
'of the HYPERLINK() worksheet function.

'Insert the following function in a standard code module:


Function HyperlinkClick()

    Set HyperlinkClick = Selection
    
    'Do whatever you like here...
    MsgBox "You clicked on cell " & Selection.Address(0, 0)

End Function


'-------------------------------------------------------------------------------

'Now in a worksheet cell, enter the followin formula:

=HYPERLINK("#HyperlinkClick()", "Text you want to Display")


'Clicking on that hyperlink will run the VBA function above.

'Notice the (#) symbol as the first character of the link_location 
'parameter. This is required for the function to work properly.
'
'
'
Posted by: Guest on March-02-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language