Excel 2010 VBA to Hyperlink Active Cell to itself, so it would lead to it's exact location from when that cell is pasted and sent in Outlook e-mail

Objective: Excel 2010 - VBA to Hyperlink Active Cell to itself, so it would lead to it's exact location on spreadsheet from when that cell is pasted and sent in Outlook e-mail. I need to keep the contents of the Excel cell intact - keep displaying whatever I have in it not related to hyperlink etc. That cell will be e-mailed. Need to be able to click on cell from Outlook e-mail message and have that Hyperlink open the spreadsheet and select that exact cell location on that spreadsheet. The only element is missing is that Hyperlinking part. The VBA code I have below bugs out (yellow highlighting) the part with Hyperlinks. Sorry if I'm not pasting code according to the rules - I probably am not understanding them. Thanks for help!

Sub H_Link_Cell_to_Self
Dim path As String
Dim sheet As String
Dim cell As String
path = Application.ActiveWorkbook.FullName
sheet = Application.ActiveSheet.Name
cell = Application.ActiveCell.Address
ActiveSheet.Hyperlinks.Add Range(Active.Cell), "path” & “\“ & “sheet” & “\“ & “cell"
End Sub
2

1 Answer

Your code looks good with exception of the line that adds the hyperlink. Here you have your variables surrounded by double-quotes which is causing them to be interpreted as literal values instead of variables.

Try this instead:

ActiveSheet.Hyperlinks.Add Range(Active.Cell), path & “\“ & sheet & “\“ & cell
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like