Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'd like to be able to insert the code below into the selected
worksheet when the user runs a macro. Is it possible to run a macro that will insert this pre-written code into a worksheet? '******************* 'paste this code into a tab. whenever it's activated it will create an index of each 'sheet in the workbook dynamically and then also put a return link on each tab '******************* Private Sub Worksheet_Activate() Dim wSheet As Worksheet Dim M As Long M = 1 With Me .Columns(1).ClearContents .Cells(1, 1) = "INDEX" .Cells(1, 1).Name = "Index" End With For Each wSheet In Worksheets If wSheet.Name < Me.Name Then M = M + 1 With wSheet .Range("H1").Name = "Start" & wSheet.index .Hyperlinks.Add Anchor:=.Range("H1"), Address:="", SubAddress:="Index", TextToDisplay:="Back to Index" End With Me.Hyperlinks.Add Anchor:=Me.Cells(M, 1), Address:="", SubAddress:="Start" & wSheet.index, TextToDisplay:=wSheet.Name End If Next wSheet End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code for my Command Button to automatically copy and insert a new | Excel Discussion (Misc queries) | |||
Macro to insert this formula automatically on start up | Excel Programming | |||
Automatically insert signature in worksheet | Excel Programming | |||
automatically insert town name after entering zip code | Excel Discussion (Misc queries) | |||
Automatically Insert Text Into Macro | Excel Programming |