Running VBA from a HYPERLINK()

前端 未结 4 1349
生来不讨喜
生来不讨喜 2020-11-30 13:43

I\'m trying to let my users send email easily from their Excel spreadsheets, which they like to use as front-ends for data entry and manipulation. My intention is to write a

4条回答
  •  情书的邮戳
    2020-11-30 13:55

    To run the function only on a click you can try entering as a subaddress:

    =HYPERLINK("#generateEmail(H2, I2, M2)", "Generate Email")
    

    and then add an extra line in the code to return the current address:

    Function generateEmail(name, manager, cc)
    
    Set generateEmail = Selection
    'Paste Outlook Code Here 
    
    End Function
    

    Note this method does not get executed on the main vba thread so to test you can insert statements in the code instead of stepping through, eg:

    Range("A10:C10") = Array(name, manager, cc)
    

提交回复
热议问题