ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Converting a value in a cell to a hyperlink in the same cell via V (https://www.excelbanter.com/excel-programming/368413-converting-value-cell-hyperlink-same-cell-via-v.html)

Sandy

Converting a value in a cell to a hyperlink in the same cell via V
 
I have a path to a file in cell B10. I want cell b10 to be converted to a
hyperlink without needing to point to a different cell (which I can do with
the worksheet HYPERLINK function.

I want to do this programmatically via VB.

I have searched prior hyperlink questions and answers on this site but have
found my case.

Thanks,

Sandy

Tom Ogilvy

Converting a value in a cell to a hyperlink in the same cell via V
 
I turned on the macro recorder and then inserted a hyperlink. Turned off the
recorder and looked at the code
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/26/2006 by OGILVTW
'

'
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
"http://www.cpearson.com/excel/duplicat.htm", TextToDisplay:= _
"http://www.cpearson.com/excel/duplicat.htm"
End Sub

this would tell me

Sub MakeHyperlink()
Range("B10").Hyperlinks.Add Anchor:=Range("B10"), _
Address:=Range("B10").Value, _
TextToDisplay:=Range("B10").Value

End Sub

which worked for me.


--
Regards,
Tom Ogilvy



"Sandy" wrote:

I have a path to a file in cell B10. I want cell b10 to be converted to a
hyperlink without needing to point to a different cell (which I can do with
the worksheet HYPERLINK function.

I want to do this programmatically via VB.

I have searched prior hyperlink questions and answers on this site but have
found my case.

Thanks,

Sandy


Sandy

Converting a value in a cell to a hyperlink in the same cell via V
 
Tom, thank you. This almost works. It does create a hyperlink to the file in
question but does not open the file. A fly over of the link reveals that the
following preceeds the path to the file:

file///then the file path displays as expected.

how do I get rid of the file///

Thank you

"Sandy" wrote:

I have a path to a file in cell B10. I want cell b10 to be converted to a
hyperlink without needing to point to a different cell (which I can do with
the worksheet HYPERLINK function.

I want to do this programmatically via VB.

I have searched prior hyperlink questions and answers on this site but have
found my case.

Thanks,

Sandy


Tom Ogilvy

Converting a value in a cell to a hyperlink in the same cell v
 
I don't know how it is getting there. I don't get that.

I put this URL in a B10

'\\Hqdadfs\data\COMMON\AA\Climate Assessment Survey.xls

this was to a file on non-mapped network share (no drive letter). I ran the
code and it creates a proper hyperlink that opens that file when it is
clicked.

I put in a path to a file on a mapped drive:

C:\Data\aa_demo.xls


that worked fine as well.

--
Regards,
Tom Ogilvy


"Sandy" wrote:

Tom, thank you. This almost works. It does create a hyperlink to the file in
question but does not open the file. A fly over of the link reveals that the
following preceeds the path to the file:

file///then the file path displays as expected.

how do I get rid of the file///

Thank you

"Sandy" wrote:

I have a path to a file in cell B10. I want cell b10 to be converted to a
hyperlink without needing to point to a different cell (which I can do with
the worksheet HYPERLINK function.

I want to do this programmatically via VB.

I have searched prior hyperlink questions and answers on this site but have
found my case.

Thanks,

Sandy


Sandy

Converting a value in a cell to a hyperlink in the same cell via V
 
Again, thankyou. I assume you did your last test using the macro you created?

PS - I also live in VA (Lake Anna)

"Sandy" wrote:

I have a path to a file in cell B10. I want cell b10 to be converted to a
hyperlink without needing to point to a different cell (which I can do with
the worksheet HYPERLINK function.

I want to do this programmatically via VB.

I have searched prior hyperlink questions and answers on this site but have
found my case.

Thanks,

Sandy



All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com