Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Creating HyperLinks in VB

Max,

Adapt the following for your use. Be careful with the _ at the
end of the lines


Activesheet.Hyperlinks.Add Anchor:= YourLinkCell.address, _
Address:="", SubAddress:= "'" + MyPreviousWorksheet.Name + "'!" _
+ Replace(YourLinkCell.Cells.Address, "$", ""), TextToDisplay:="'" _
+ YourLinkCell.Cells.Formula

Notice how the sheetname is concatenated. Also, how the Absolute sign
"$" is removed from the address. I chose the to show the Formula as
the blue link text display. Of course you could use
YourLinkCell.Cells.Value

HTH EagleOne


Max wrote:
Hi!

I'm using the following code to try and create automatic HyperLinks in my
workbook:

Sheet2.Cells(i + 5, 2).Value = strENGINE
Sheet2.Cells(i + 5, 2).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'" & strENGINE & "'!A1", TextToDisplay:=strENGINE
With Selection.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleSingle
.ColorIndex = 5
End With

where strENGINE is the name of a worksheet in the same workbook. However,
when I click on the created link, I get a "Reference is not valid." error.
What can I do to correct this?

Note, strENGINE may contain a hypen in it - does this cause issues as well?
--
Thanks!
Max


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating hyperlinks David Baker Excel Discussion (Misc queries) 2 December 21st 08 06:08 PM
help creating new hyperlinks programmatically J Links and Linking in Excel 1 January 14th 08 08:15 AM
Creating hyperlinks Fred Excel Discussion (Misc queries) 0 February 21st 07 03:13 PM
Self creating Hyperlinks HELP PLS Paul Excel Discussion (Misc queries) 3 February 6th 07 10:33 AM
creating hyperlinks Archana Jain Excel Worksheet Functions 1 November 14th 05 04:56 AM


All times are GMT +1. The time now is 07:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"