VBA - Convert emails to hyperlinks

On a sheet column I have email addresses and I want to convert them to hyperlinks so that when I click them, I open my email client and send and email to that address. I can use a macro to change the content of that cell to a hyperlink. Here’s the code for that:

Sub Convert_to_Hyperlink()

    Dim rng As Range
    Dim cell As Range

    'Define here the range where you have your emails values
    rng = Range("B2:B100")

    For Each cell In rng
        'If the cell is blank, ignore it
        If cell.Value <> "" Then
            cell.Hyperlinks.Add ANCHOR:=cell, Address:="mailto:" & cell.Value, TextToDisplay:=cell.Value
        End If
    Next cell

End Sub

0 comentários: