Create Hyperlink In Email From Relative Cell Value

wguidry

New Member
Joined
Apr 22, 2003
Messages
42
I need to create a hyperlink from the value in a cell. It is a URL that will be populated in an email.

It is located in the code below at:
Msg = Msg & "Please click this link to view the map: " & vbCrLf
Msg = Msg & ActiveCell.Offset(0, -12).Value & vbCrLf & vbCrLf

I want ActiveCell.Offset(0, -12).Value to be converted to a hyperlink instead of showing only as plain text.

Any thoughts?
Thanks,

--------------------

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub Send_R1()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
' On Error GoTo HandleErrors
'HandleErrors:
'Exit Sub
If ActiveCell.Offset(0, 3).Value = "REMOVE PUB. OR SEND TERR." And ActiveCell.Value = "SEND" Then
If MsgBox("Are you sure you want to email Territory " & ActiveCell.Offset(0, -13).Value & " to " & ActiveCell.Offset(0, -5).Value & " " & ActiveCell.Offset(0, -4).Value & " " & ActiveCell.Offset(0, -3).Value & "?", vbYesNo, "Confirm") = vbYes Then
ActiveCell.Offset(0, -1).Value = Date
Email = ActiveCell.Offset(0, -2).Value
Subj = "RE: Your Dickinson Cong. Territory Request"
Msg = Msg & "Hello " & ActiveCell.Offset(0, -5).Value & " " & ActiveCell.Offset(0, -3).Value & ". Thank you for your Territory request." & vbCrLf & vbCrLf
Msg = Msg & "You have been assigned Territory:" & vbCrLf
Msg = Msg & ActiveCell.Offset(0, -13).Value & vbCrLf & vbCrLf
Msg = Msg & "Please click this link to view the map: " & vbCrLf
Msg = Msg & ActiveCell.Offset(0, -12).Value & vbCrLf & vbCrLf
Msg = Msg & "This Territory will expire on " & ActiveCell.Offset(0, 2).Value & "." & vbCrLf & vbCrLf
Msg = Msg & "Your Brothers," & vbCrLf
Msg = Msg & "Dickinson Congregation"
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
Application.Wait (Now + TimeValue("0:00:05"))
Application.SendKeys "{Tab}{Tab}{Tab}{Tab}{Tab}^{End}{Return}{Return}^v"
Application.SendKeys "%s"
MsgBox "The Territory Has Been Sent"
ActiveSheet.Cells(ActiveCell.Row, 1).Select
ActiveCell.Offset(0, 21).Select
Selection.Copy
ActiveCell.Offset(0, -1).Select
ActiveSheet.Paste
ActiveCell.Offset(0, 2).Select
Selection.Copy
ActiveCell.Offset(0, -1).Select
ActiveSheet.Paste
ActiveCell.Offset(0, -8).Select
Selection.Copy
ActiveCell.Offset(0, 9).Select
ActiveSheet.Paste
End If
End If
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try this:
Change "Click Here" to whatever label you want on the Hyperlink.
I found this solution at the following link:

Code:
Msg = Msg & ActiveCell.Offset(0, -12).Value  & """ >Click Here& vbCrLf & vbCrLf
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top