i have some code wrote to copy a Hidden Sheet; Rename it based on a cell and hyperlink that cell to the sheet. I'd like to add a couple things to the code but struggling to figure it out. Below is the full sequence I would like it to do. (step 4 is what I need help with)
1. Copy Hidden Sheet
2. Rename the sheet to the active cell I'm in
3. Hyperlink the active cell to the sheet
4. Hide the new sheet
5. Keep the hyperlink functional
Note: I also have a button on the sheet that is linked to the main page of my workbook - how can I add function to hide the sheet when I go back to that page?
Sub add_new_sheet()
CarryOn = MsgBox("ARE YOU IN THE PROJECT NAME CELL?", vbYesNo, "CREATE NEW PROJECT?")
If CarryOn = vbYes Then
Dim sheet_name_to_create As String
Dim sh As Worksheet, nsh As Worksheet 'nsh = sheet_name_to_create
Dim nrng As Range
Dim cont As Worksheet
Dim oRng As Range
sheet_name_to_create = ActiveCell.Value
Set oRng = ActiveCell
Set sh = Sheets("PRODUCTION SCHEDULE")
For rep = 1 To (Worksheets.Count)
If UCase(Sheets(rep).Name) = UCase(sheet_name_to_create) Then
MsgBox "ALREADY EXISTS - CHECK YOUR PROJECTS"
Exit Sub
End If
Next
Sheets("MASTER PT SHEET").Visible = True
Sheets("MASTER PT SHEET").Copy after:=Sheets(Sheets.Count)
ActiveWindow.ActiveSheet.Name = sheet_name_to_create
Sheets("MASTER PT SHEET").Visible = False
sh.Activate
sh.Hyperlinks.Add oRng, "", "'" & sheet_name_to_create & "'!A1", _
"Go to " & sheet_name_to_create, sheet_name_to_create
Set oRng = Nothing
End If
End Sub
Bookmarks