ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   hyperlink formula to its result in same cell (https://www.excelbanter.com/excel-programming/382127-hyperlink-formula-its-result-same-cell.html)

arne

hyperlink formula to its result in same cell
 
I'm stucked; what am I doing wrong?

problem, get rid of the hyperlink formula and have the name in A show,
'and the link to open when activate1
Arne

Sub make_hyperlink()
' Sheet filled with names in A col and their belonging url in B col
' create a hyperlink with the name (A)AND url from (B) in col C
' And remove the formula Hyperlink, but keep the result in C
'Example in COL
'A: Google
'B: http://www.google.com/
'C: gives Google with hyperlink

Dim myrow As Long
With ActiveSheet
myrow = Range("A" & Rows.Count).End(xlUp).Row
Range("C1:C" & myrow).Formula
="=trim(HYPERLINK(RC[-1],RC[-2]))"
End With
End Sub





NickHK

hyperlink formula to its result in same cell
 
Arne,
If you do not want the HYPERLINK function, don't use it.
This is what I got recording a macro of the cell right-clickhyperlink
action:

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"Sheet1!A1", TextToDisplay:="Sheet1!A1"

You should be able to change this to include the values of Range("A1") and
Range("B1") .

NickHK

"arne" wrote in message
...
I'm stucked; what am I doing wrong?

problem, get rid of the hyperlink formula and have the name in A show,
'and the link to open when activate1
Arne

Sub make_hyperlink()
' Sheet filled with names in A col and their belonging url in B col
' create a hyperlink with the name (A)AND url from (B) in col C
' And remove the formula Hyperlink, but keep the result in C
'Example in COL
'A: Google
'B: http://www.google.com/
'C: gives Google with hyperlink

Dim myrow As Long
With ActiveSheet
myrow = Range("A" & Rows.Count).End(xlUp).Row
Range("C1:C" & myrow).Formula
="=trim(HYPERLINK(RC[-1],RC[-2]))"
End With
End Sub








All times are GMT +1. The time now is 03:38 AM.

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