Last active
April 16, 2017 15:57
-
-
Save ateneva/0498f9b389c96b71d737b120f4fcbbb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub AddRemoveHyperLinks() | |
Dim prv As String | |
Dim Cell As Range | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
'written by Angelina Teneva, September 2016 | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
For Each Cell In ActiveSheet.Range("B2:B" & ActiveSheet.UsedRange.Rows.Count) | |
If Cell.Hyperlinks.Count = 0 Then | |
prv = Cell.Value | |
If InStr(1, Cell, "@", vbTextCompare) <> 0 Then | |
Cell.Hyperlinks.Add Anchor:=Cell, Address:="mailto:" & prv 'adds hyperlink to an e-mail | |
Else | |
Cell.Hyperlinks.Add Anchor:=Cell, Address:=prv 'adds hyperlink to a website | |
End If | |
Else | |
Cell.Hyperlinks.Delete 'delete a hyperlink from a cell | |
End If | |
Next Cell | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment