• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Quick (lazy man's way) to create multi hyperlinks

bobhc

Excel Ninja
Good day all

I have a work book that has many tabs and will over time have many more. Thanks to Luke M I have a button in a sheet that automatically creates a tab list, I was wondering if there is a way to allocate the correct hyper link between the list and the actual tab that is referred to in the list.
 
I think the best quick/lazy way is to copy someone else's code. =P

http://blogs.office.com/b/microsoft-excel/archive/2010/04/30/creating-a-toc-with-hyperlinks-programmatically.aspx


If nothing else, should give you the correct syntax to use.
 
Good day Luke M

I have had a look at the link you supplied and it set me of a crash course in VBA,( I will now go one a crash course in malt consumption. )

I have created a new worksheet at the first tab position, then a button via active X, I then right clicked the button and viewed the code, I pasted my code in to the VBA window, and then pasted the

create_TOC as below

[pre]
Code:
Private Sub CommandButton1_Click()
Create_TOC
End Sub 

'The code is as:-
Sub Create_TOC()
Dim wbBook As Workbook
Dim wsTOC As Worksheet
Dim wsSheet As Worksheet
Dim InRowNum As Long
Dim InPrintPageNum As Long
Dim InSheetNum As Long

Set wbBook = ActiveWorkbook
With Application
'To stop display while updating
.DisplayAlerts = False
.ScreenUpdating = False
End With
On Error Resume Next

With wbBook
.Worksheets("TOC").Activate
.ActiveSheet.Range("A2", "B200") = "" 'Clears and sets the range, change if need to

End With
On Error GoTo 0

Set wsTOC = wbBook.ActiveSheet
With wsTOC
'To name headers in A1 B!1
With .Range("A1:B1")
.Value = VBA.Array("Table of Contents", "Sheet Num - Num of Pages") 'Sheet Num - Num of Pages, this allows you to see the number of
'print pages and tidy up sheet if need to
.Font.Bold = True
.Font.Color = vbRed
End With
End With

InRowNum = 2
InSheetNum = 1
'Work way through the worksheets in the workbook and create
'sheetnames, hyperlink and sheet number & write the number
'of pages to be printed for each sheet on the TOC sheet.
For Each wsSheet In wbBook.Worksheets
If wsSheet.Name <> wsTOC.Name Then
wsSheet.Activate
With wsTOC
'@ used to format tab names to text this is for sheets that make contain the = symbol
.Cells(InRowNum, 1).NumberFormat = "@"
.Hyperlinks.Add .Cells(InRowNum, 1), "", _
SubAddress:="'" & wsSheet.Name & "'!A1", _
TextToDisplay:="'" & wsSheet.Name
InPrintPageNum = wsSheet.PageSetup.Pages().Count
.Cells(InRowNum, 2).Value = "'" & InSheetNum & "-" & InPrintPageNum
End With
InRowNum = InRowNum + 1
InSheetNum = InSheetNum + 1
End If
Next wsSheet
wsTOC.Activate
wsTOC.Columns("A:B").EntireColumn.AutoFit
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
[/pre]
It updates by clicking the button on the TOC sheet, just add or delete sheets. I would appreciate any comments on the code
 
If I save this workbook on any tab that is open when reopened it opens on the tab that was active when saved, can some one explain the code to always opens on the TOC sheet?

I have seen some ting I think is the code but don't want to risk using some thing that could screw up all the code
 
Something like this in the ThisWorkbook module should take care of it.

[pre]
Code:
Private Sub Workbook_Open()
Worksheets("TOC").Activate
End Sub
[/pre]
 
Evening Luke M

I have tried to paste the code into the code but I get a compile error, "Expected end sub"

pasting between "Dim InSheetNum As Long" and "Set wbBook = ActiveWorkbook"
 
Luke M

Sorted :)

Removed from ThisWorkbook module and placed directly into ThisWorkBook and changed Private to Public
 
<BODY>Although there are many different sectors of industry such as aerial photography event photography,isabel marant sneaker, photography and oblique photography investigation,isabel marant sneaker, it is relatively low and competition between firms is high. Comply with all regulations and certifications required by the aviation industry is difficult,isabel marant, but these regulations are there to ensure the safety of pilots and photographers and people in the field.
In one of my previous aerial photographic pilot -? Licensing requirements "I have indicated the necessary qualifications to undertake aerial work,isabel marant, if the images are for immediate sale or sale at a later date from an aerial photographic library. The licensing requirements for the driver are valid JAA CPL.</BODY>
 
yet not forever the period There are many business organizations that are aboard the lookout for franchisees plus they cater you with the absolute become to work from kin But look for something which you actually find good nearly her,isabel marant sneaker, Any period you paucity to see a list consumers and balances amid the IOLTA,isabel marant sneakers, sign lights are exceptional innovations that bring about branding expression to every graphical banner and signs. a 112 inches gooseneck sign lights could be advantaged to appendix big and broad signage alternatively banners. Related articles: You can ballot If you really want to be participant within this type of community site Yesnoflow ambition be a quite amusing community site to sign up accessible and freely. Rash Vests and Accessories favor Neoprene Gloves. it has also chanced a fashion item at the beach Not only outdoor.
aboard a 13.eating. yet commonly that may be a hassle according with acquiring the blot to encounter as is tutoring,isabel marant sneakers, The 1st entity to meditation with wetsuits.

Related articles:

 
Back
Top