Adding a link in email macro using a cell value

mm424

New Member
Joined
May 2, 2024
Messages
2
Office Version
  1. Prefer Not To Say
Platform
  1. Windows
Hi all, I'm trying to create a macro to open (but not send) multiple emails at a time. I'm hardly an expert with macros but I'm working my way through this to make a small part of my job a little easier and this works except for one relatively small aspect. I've posted the code below -- I need the part that is & "<br><b>Opportunity: &nbsp&nbsp</b>" & Range("E" & r).Value & "" _ to open in the email as a hyperlink as the actual cell values in column E are URLs. It's fine if the text for the link is just the URL, but ideally it will appear in the email as a link. So in the new email that pops up it should look like:

Opportunity: https://blahblahblah.com

I know this isn't a huge deal and I can just enter a space after the URL once the new email opens in Outlook and it'll become a link but if I'm going to do this, I want to try and go all the way with it.

VBA Code:
Sub SendMultipleEmails()
 
      Dim OutApp As Object, OutMail As Object, lastRow As Integer, r As Integer
      Dim bodyHeader As String, bodyMain As String, bodySignature As String
      Set OutApp = CreateObject("Outlook.Application")
 
      lastRow = Cells(Rows.Count, "B").End(xlUp).Row
    
 
      For r = 2 To lastRow
          Set OutMail = OutApp.CreateItem(0)
          With OutMail
              .To = Range("B" & r).Value
              .Subject = Range("C" & r).Value & " - " & Range("D" & r).Value & " " & Range("F" & r).Value & " " & Range("G" & r).Value & " " & Range("H" & r).Value & " - " & Range("I" & r).Value
    
              .HTMLBody = "Hello team, <P>Please create CPQs for <b>" & Range("D" & r).Value & "</b> using the attached " & Range("F" & r).Value & " " & Range("G" & r).Value _
              & " proposal.  This is a " & Range("H" & r).Value & "." _
              & "<br><b>Opportunity: &nbsp&nbsp</b>" & Range("E" & r).Value & "" _


              .Display
              
          End With
      Next r
      Set OutMail = Nothing
      Set OutApp = Nothing
  End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try something like this:


VBA Code:
"<br><a href='" & Range("E" & r).Value & "'><b>Opportunity: </b>" & Range("E" & r).Value & "</a>"
 
Upvote 0
Try something like this:


VBA Code:
"<br><a href='" & Range("E" & r).Value & "'><b>Opportunity: </b>" & Range("E" & r).Value & "</a>"

That worked! Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,645
Members
449,461
Latest member
kokoanutt

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