PDA

View Full Version : Solved: Convert Cell to Hyperlink



JKwan
03-04-2005, 04:03 PM
How do I convert a cell into Hyperlink. I've done some processing and build up my web address, the end result looks like below - location in column C ....

http://www.transcanada.com/Alberta/reports/stop_plan/2005_03_03_16_25.html http://www.transcanada.com/Alberta/reports/stop_plan/2005_03_02_16_04.html http://www.transcanada.com/Alberta/reports/stop_plan/2005_03_01_15_55.html http://www.transcanada.com/Alberta/reports/stop_plan/2005_02_28_16_16.html http://www.transcanada.com/Alberta/reports/stop_plan/2005_02_25_15_55.html http://www.transcanada.com/Alberta/reports/stop_plan/2005_02_24_16_10.html
However, they are not hyperlinked to the location, they are more or less "text".

Instead of me clicking on the cell and copy then paste into a Web Browser, how do I convert it to an "actual" hyperlink?

Thanks

Paleo
03-04-2005, 04:11 PM
Try this:


Sub hyper()
Dim i As Long, Texto As String
For i = 1 To Range("C65536").End(xlUp).Row
On Error Resume Next
Texto = Range("C" & i)
On Error GoTo 0
ActiveSheet.Hyperlinks.Add Range("C" & i), Texto
Next
End Sub

JKwan
03-07-2005, 08:27 AM
Carlos:
Thank you, that worked really good.

werafa
05-21-2014, 11:33 PM
Thanks Carlos,

I needed a bit more flexibility, but you did put me on the right track.
here is another take on the answer


Sub SetHyperFormat()
Dim lastRow As Long
Dim firstRow As Long
Dim myRange As Range
Dim myString As String
Dim myRow As Long


lastRow = Sheet1.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
firstRow = FindStartRow 'a seperate function
Set myRange = GetRange("ExportSeries") 'a seperate function

On Error Resume Next
For myRow = firstRow + 1 To lastRow
myString = Trim(myRange.Cells(myRow).Value)
If myString <> "" Then 'could add a test for a valid url here
Application.ActiveSheet.Hyperlinks.Add myRange.Cells(myRow), myString
End If
Next myRow
On Error GoTo 0

Set myRange = Nothing
End Sub