ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hyperlinks from one excel sheet to another in VBA (https://www.excelbanter.com/excel-programming/395761-hyperlinks-one-excel-sheet-another-vba.html)

Lindleman

Hyperlinks from one excel sheet to another in VBA
 
I am trying to programmatically insert a hyperlink into a cell on
sheetA (static name) from various other workbooks whose names all
differ. I want to be able to open the referenced sheets from a master
sheet. I tried to record a macro that copies and pastes as a link, but
it does not record the paste link function. Since the sheet names are
all variables except for the master, I know somewhere I need a cell
reference. i.e. Cell("filename"), but I need this to run inside a VBA
macro. Can anyone help me on this code?

Thanks in advance!


Gary''s Student

Hyperlinks from one excel sheet to another in VBA
 
Try something like this:

Sub hyper_put()
Dim s As String, t As String
s = Chr(34)
t = "=HYPERLINK(" & s
t = t & "file:///C:\Documents and Settings\Owner\Desktop\Book2.xls#Sheet2!B9"
t = t & s & ")"
Range("A1").Value = t
End Sub

The contents of A1 will be:

=HYPERLINK("file:///C:\Documents and
Settings\Owner\Desktop\Book2.xls#Sheet2!B9")


--
Gary''s Student - gsnu200738


"Lindleman" wrote:

I am trying to programmatically insert a hyperlink into a cell on
sheetA (static name) from various other workbooks whose names all
differ. I want to be able to open the referenced sheets from a master
sheet. I tried to record a macro that copies and pastes as a link, but
it does not record the paste link function. Since the sheet names are
all variables except for the master, I know somewhere I need a cell
reference. i.e. Cell("filename"), but I need this to run inside a VBA
macro. Can anyone help me on this code?

Thanks in advance!



Lindleman

Hyperlinks from one excel sheet to another in VBA
 
On Aug 16, 10:36 pm, Lindleman wrote:
I am trying to programmatically insert a hyperlink into a cell on
sheetA (static name) from various other workbooks whose names all
differ. I want to be able to open the referenced sheets from a master
sheet. I tried to record a macro that copies and pastes as a link, but
it does not record the paste link function. Since the sheet names are
all variables except for the master, I know somewhere I need a cell
reference. i.e. Cell("filename"), but I need this to run inside a VBA
macro. Can anyone help me on this code?

Thanks in advance!


Can anyone help me?



All times are GMT +1. The time now is 07:40 PM.

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