In my Excelsheet, i use a table with datasource from sql-server.
One of the column includes the phone-number, another one the mailaddress.
Now i want to create a hyperlink like tel:09999999
or mailto:test@test.com
to open the default windows-application for starting a call or writeing an email.
The format of the cell is general.
Unfortunally the hyperlink comes as plain-text not as hyperlink. I see the formula like =hyperlink("tel:09999999";"09999999")
. When I click in the cell, press the [F2]
-key and press return, then excel change the cell-value to a "correct" hyperlink.
The second idea I trying was to write a macro for all this cells. but the performance is not ok, I have about 20000 rows with 5 columns, so excel run about 1minute only for creating the hyperlink. The Code looks like:
lastrow = ActiveSheet.Cells(Cells.Rows.Count, 1).End(xlUp).Row
For i2 = 4 To lastrow
'Phone1
Worksheets("Report").Cells(i2, 11).Select
If Len(Selection.Value) > 0 Then
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="tel:" + CStr(Selection), TextToDisplay:=CStr(Selection)
End If
'Phone2
Worksheets("Report").Cells(i2, 12).Select
If Len(Selection.Value) > 0 Then
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="tel:" + CStr(Selection), TextToDisplay:=CStr(Selection)
End If
'Phone3
Worksheets("Report").Cells(i2, 13).Select
If Len(Selection.Value) > 0 Then
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="tel:" + CStr(Selection), TextToDisplay:=CStr(Selection)
End If
'Mail1
Worksheets("Report").Cells(i2, 14).Select
If Len(Selection.Value) > 0 Then
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="mailto:" + CStr(Selection), TextToDisplay:=CStr(Selection)
End If
'Mail2
Worksheets("Report").Cells(i2, 15).Select
If Len(Selection.Value) > 0 Then
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="mailto:" + CStr(Selection), TextToDisplay:=CStr(Selection)
End If
Next i2