Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / August 2007

Tip: Looking for answers? Try searching our database.

Macro to copy and paste link to current sheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lindleman - 17 Aug 2007 19:01 GMT
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!
Brian Withun - 17 Aug 2007 21:00 GMT
> I am trying to programmatically insert a hyperlink into a cell on
> sheetA (static name) from various other workbooks whose names all
[quoted text clipped - 7 lines]
>
> Thanks in advance!

Here's an example from a product I've been working on:

   Dim LGUP As Worksheet

   Dim LEDSRow As Long
   Dim LGUPRow As Long

   Dim Contents As String

   ' some names of worksheet tabs
   const LEDSDataSheet = "LEDS_Format"
   const LargeUpTimesSheet = "Large_Uptimes"

   Set LGUP = Sheets(LargeUpTimesSheet)

   LEDSRow = 3
   LGUPRow = 5

   Contents = "=" & LEDSDataSheet & "!" & "$B$" & Mid(Str(LEDSRow),
2)

   With LGUP

       ' prepare a hyperlink directly to this large value
       .Hyperlinks.Add Anchor:=LGUP.Cells(LGUPRow, 3), _
                       Address:="", _
                       SubAddress:=Contents, _
                       TextToDisplay:="Go There"
   End With

It creates a hyperlink on one sheet to another sheet.  This code is
just cut out of a larger subroutine but all the important parts should
be here for a workable example.

I notice that, when it's done, the hyperlink has a full reference to
the destination sheet; it's full name and filesystem location.  I
imagine that this will work from one workbook to another.

Brian Herbert Withun

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.