griffinwebnet
New Member
- Joined
- Aug 4, 2011
- Messages
- 4
I have written a macro to extract the addresses from hyperlinks, and paste them in the cell to the right, it them removes the 'mailto:' if its an email address, and its supposed to delete the contents of the cell if it starts with 'http:' because were not interested in web sites. however it extracts and removes mailto: but in the last step it removes random email addresses from the list as well. addresses that dont have http: and it sometimes fails to remove actual web addresses.
Here is my code:
-JL
Here is my code:
Code:
Sub ExtractHL()
'Extracts the destination of all hyperlinks
Dim HL As Hyperlink
For Each HL In ActiveSheet.Hyperlinks
HL.Range.Offset(0, 1).Value = HL.Address
Next
'Removes Mailto from the destination addresses if an email
Cells.Replace What:="mailto:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
'Deletes all non email addresses
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If cell.Text >= "http:" Then cell.ClearContents
Next
'Removes All HyperLinks
Cells.Hyperlinks.Delete
End Sub
-JL