ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hyperlinks.Add does nothing (https://www.excelbanter.com/excel-programming/343968-hyperlinks-add-does-nothing.html)

itarnak[_13_]

Hyperlinks.Add does nothing
 

hi,

IN VBA
i have copied one sheet in another (copy/pastespecialthe whole sheet
with values & formats:(i don't want to use the Paste method, onl
PasteSpecial).
Now i want to copy hypelinks too so i do that:

For Each h In FirstSheet.Hyperlinks
SecondSheet.Hyperlinks.Add(Anchor:=h.Range, Address:=h.Address
TextToDisplay:=Switch(Not IsEmpty(h.TextToDisplay), h.TextToDisplay
IsEmpty(h.TextToDisplay), h.TextToDisplay))
Next h


but the links are not copied: SecondSheet has no links....
In a debugguer, i can see that the loop is running fine, bu
SecondSheet.HyperLinks.Count is always 0....


What does that mean?

Regards,
iTarna

--
itarna
-----------------------------------------------------------------------
itarnak's Profile: http://www.excelforum.com/member.php...fo&userid=2786
View this thread: http://www.excelforum.com/showthread.php?threadid=47971


Leith Ross[_127_]

Hyperlinks.Add does nothing
 

Hello Itarnak,

The problem appears to be the Hyperlink address, you are using th
cell's address instead of its contents. Change your code to this...


Code
-------------------

For Each h In FirstSheet.Hyperlinks
SecondSheet.Hyperlinks.Add(Anchor:=h.Range, Address:=h.Range.Value, TextToDisplay:=Switch(Not IsEmpty(h.TextToDisplay), h.TextToDisplay, IsEmpty(h.TextToDisplay), h.TextToDisplay))
Next h

-------------------

--
Leith Ros

-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=47971



All times are GMT +1. The time now is 08:34 AM.

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