PDA

View Full Version : need vba code to automatically format cell as hyperlink



HCI
02-06-2010, 04:18 PM
i have a database i am putting together that is a shared workbook. when a workbook is shared and you type an email address in, it doesnt convert it to a hyperlink.

does anybody know of a macro that will do this when i enter an email address in?

i only need it to be in the entire column S

thanks.

mbarron
02-06-2010, 08:00 PM
Add this change event to the module for the sheet. It will add a mailto: hyperlink to values entered in the S column that contain an @ in the entry.


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("S:S")) Is Nothing Then
If InStr(Target, "@") > 0 Then
Hyperlinks.Add Target, "mailto:" & Target
End If
End If
End Sub