ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copying hyperlinks (https://www.excelbanter.com/excel-programming/296730-copying-hyperlinks.html)

john sharkey

copying hyperlinks
 
Does anyone know how to write the VBA code copy a
hyperlink I tried to record a macro where I select a cell
that has a hyperlink. I choose edit HYPERLINK, COPY
HYPERLINK and then I select cell and paste.

here is the code it generates.


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 4/29/2004 by JOHN F SHARKEY
'

'
Range("A8").Select
Selection.Copy
Range("E8").Select
ActiveSheet.Paste
End Sub
Any way around this?

Thanks

david mcritchie

copying hyperlinks
 
Hi John,
for the simplest in the form of a user defined function:

Function HyperlinkAddress(cell)
On Error Resume Next
HyperlinkAddress = cell.Hyperlinks(1).Address
if hyperlinkaddress = 0 then hyperlinkaddress = ""
End Function

For some additional codings for other links, see
http://www.mvps.org/dmcritchie/excel/buildtoc.htm#url
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"john sharkey" wrote ...
Does anyone know how to write the VBA code copy a hyperlink





All times are GMT +1. The time now is 01:11 PM.

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