LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Hyperlink Question

Change
SubAddress:=ws.Name & "!A1

to

SubAddress:="'" & wsName & "'!A1"

Note that I have put -- doublequote singlequote doublequote & <-- before
swName

and in "!A1" I have added a singlequote after the first doublequote.

Regards,
Tom Ogilvy


onliner wrote in message
news:hMfQa.925$Ze.806@fed1read03...
The following code creates a Table of Contents complete with hyperlinks to
each of the worksheets within the workbook.
The problem is that the hyperlinks only work for sheets with one name, for
example, "sheet1". For sheets with multi-word names like "sheet one", the
hyperlinks don't work.
Anyone know how to fix this?

Sub TableOfContents2()

Dim ws As Worksheet, wsTOC As Worksheet
Dim r As Long
Application.ScreenUpdating = False
Set wsTOC = ActiveWorkbook.Worksheets.Add
(befo=ActiveWorkbook.Sheets(1))
wsTOC.Name = "Table of Contents"
wsTOC.Range("A1") = "Table of Contents"
wsTOC.Range("A1").Font.Size = 18
r = 3
For Each ws In ActiveWorkbook.Worksheets
If ws.Name < wsTOC.Name Then
wsTOC.Hyperlinks.Add anchor:=wsTOC.Cells(r, 1), Address:="", _
SubAddress:=ws.Name & "!A1", TextToDisplay:=ws.Name
r = r + 1
End If
Next
Application.ScreenUpdating = True
End Sub




 
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
Hyperlink Question stew Excel Discussion (Misc queries) 2 February 28th 09 06:18 PM
Hyperlink Question Micky Excel Discussion (Misc queries) 1 August 20th 08 09:25 AM
Hyperlink Question Fill-in Form General Questions Excel Discussion (Misc queries) 0 April 25th 08 07:19 PM
hyperlink question hartjezt Excel Discussion (Misc queries) 2 January 24th 06 07:38 PM
Hyperlink Question Phil Osman Excel Discussion (Misc queries) 4 March 29th 05 03:11 AM


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

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"