Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VBA Hyperlink Question

Thanks, Tom.
Did you get a chance to test this?
I can't get it to work.
Appreciate your feedback.


"Tom Ogilvy" wrote in message
...
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






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Hyperlink Question

Table of Contents

Sheet5
Master
Sheet 3
Sheet one
Master (2)
Master (3)


is an example and all the hyperlinks worked.

--
Regards,
Tom Ogilvy


Tom Ogilvy wrote in message
...
Yes, before posted, I did and it worked fine.

Perhaps you are not making the change correctly

Here is the whole routine - copy and paste it into a new module zand test

it

Sub TableOfContents2_AAA()

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
'wsTOC.Cells(r, 1).Value = ws.Name
r = r + 1
End If
Next
Application.ScreenUpdating = True
End Sub

I tested it in Excel 97 which did not have the TextToDisplay argument, so

I
used the value of the cell, but I have commented out that line and

restored
the TextToDisplay argument.


--
Regards,
Tom Ogilvy


onliner wrote in message
news:53iQa.942$Ze.503@fed1read03...
Thanks, Tom.
Did you get a chance to test this?
I can't get it to work.
Appreciate your feedback.


"Tom Ogilvy" wrote in message
...
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










  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VBA Hyperlink Question

Thanks, Tom.
Worked perfectly.


"Tom Ogilvy" wrote in message
...
Table of Contents

Sheet5
Master
Sheet 3
Sheet one
Master (2)
Master (3)


is an example and all the hyperlinks worked.

--
Regards,
Tom Ogilvy


Tom Ogilvy wrote in message
...
Yes, before posted, I did and it worked fine.

Perhaps you are not making the change correctly

Here is the whole routine - copy and paste it into a new module zand

test
it

Sub TableOfContents2_AAA()

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
'wsTOC.Cells(r, 1).Value = ws.Name
r = r + 1
End If
Next
Application.ScreenUpdating = True
End Sub

I tested it in Excel 97 which did not have the TextToDisplay argument,

so
I
used the value of the cell, but I have commented out that line and

restored
the TextToDisplay argument.


--
Regards,
Tom Ogilvy


onliner wrote in message
news:53iQa.942$Ze.503@fed1read03...
Thanks, Tom.
Did you get a chance to test this?
I can't get it to work.
Appreciate your feedback.


"Tom Ogilvy" wrote in message
...
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












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
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 12:08 AM.

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

About Us

"It's about Microsoft Excel"