Hi everyone,
I have a macro that creates a new worksheet and then adds a hyperlink to a main index page, however it's adding the hyperlink to whatever cell I happen to have clicked into rather than into a list.
In the sheet "Index" I need a hyperlink for the newly created worksheet to be added under the last one already there. Is there a way to do this please?
The code I'm using at the minute looks like this:
Thanks in advance!
Nia
I have a macro that creates a new worksheet and then adds a hyperlink to a main index page, however it's adding the hyperlink to whatever cell I happen to have clicked into rather than into a list.
In the sheet "Index" I need a hyperlink for the newly created worksheet to be added under the last one already there. Is there a way to do this please?
The code I'm using at the minute looks like this:
VBA Code:
Sub NewRecipe()
Dim strName As String
Dim strLink As String
'get the name
'InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context])
strName = InputBox("Enter Recipe Name.", "NAME COLLECTOR")
'Exit sub if Cancel button used or no text entered
If strName = vbNullString Then Exit Sub
MsgBox "Creating Tab " & strName
'create new tab, rename new tab
Sheets("Recipe Template").Copy After:=Worksheets(Worksheets.Count)
Sheets("Recipe Template (2)").Name = strName
Sheets("Index").Select
Application.CutCopyMode = False
'create hyperlink to new tab
strLink = "'" & strName & "'!A1"
Range("A3").EntireColumn.AutoFit
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
strLink, TextToDisplay:=strName
Range("A3").EntireColumn.AutoFit
End Sub
Thanks in advance!
Nia