A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
I took some time to recreate your scenario based on what you described and tested it in my own environment, and it seems to be working as expected.
You can try using the macro below to achieve what you’re looking for, where each item in the list on the Dashboard sheet is also hyperlinked to its corresponding duplicated sheet:
Sub CopyAndRenameSheets()
Dim wList As Worksheet
Dim wTemplate As Worksheet
Dim wNew As Worksheet ' Reference to the newly created sheet
Dim wOld As Worksheet ' Reference to an existing sheet with the same name (if any)
Dim r As Long
Dim lastRow As Long
Dim newName As String ' Holds the name taken from the list
' Turn off screen flickering to speed up execution
Application.ScreenUpdating = False
' Turn off confirmation prompts so deleting old sheets runs silently
Application.DisplayAlerts = False
' Change "Dash Board" to the exact name of the sheet holding your list
Set wList = ThisWorkbook.Sheets("Dash Board")
' Change "S1" to the exact name of the sheet you want to copy
Set wTemplate = ThisWorkbook.Sheets("S1")
' Finds the last used row in Column C of your list sheet
lastRow = wList.Cells(wList.Rows.Count, "C").End(xlUp).Row
' Loops down Column C (from row 21 to the end of your list)
For r = 21 To lastRow
' Skip empty cells so no blank sheet/link is created
If Trim(wList.Range("C" & r).Value) <> "" Then
' Read the target sheet name from the list cell
newName = Trim(wList.Range("C" & r).Value)
' --- NEW: Delete any existing sheet that already has this name ---
Set wOld = Nothing
On Error Resume Next
' Try to grab an existing sheet with the same name
Set wOld = ThisWorkbook.Sheets(newName)
On Error GoTo 0
If Not wOld Is Nothing Then
' Never delete the template sheet itself
If wOld.Name <> wTemplate.Name Then wOld.Delete
End If
' ----------------------------------------------------------------
' Copies the template sheet and places it at the very end
wTemplate.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
' --- NEW: Reference the newly created sheet ---
Set wNew = ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
' Renames the newly created sheet based on the list
On Error Resume Next
wNew.Name = newName
On Error GoTo 0
' --- NEW: Capture the ACTUAL sheet name (in case rename was adjusted) ---
newName = wNew.Name
' --- NEW: Remove any existing hyperlink in the cell first ---
' Avoids duplicate/broken links when the macro is run again
wList.Range("C" & r).Hyperlinks.Delete
' --- NEW: Add an internal hyperlink from the list cell to the new sheet (cell A1) ---
' The quotes around the sheet name allow names that contain spaces
wList.Hyperlinks.Add _
Anchor:=wList.Range("C" & r), _
Address:="", _
SubAddress:="'" & newName & "'!A1", _
TextToDisplay:=newName
End If
Next r
' Restore alerts and screen updating
Application.DisplayAlerts = True
Application.ScreenUpdating = True
' Notify
MsgBox "Done! Sheets were recreated and hyperlinked successfully.", vbInformation
End Sub
If it doesn’t work as expected or you run into any issues, feel free to get back to me anytime. I’d be happy to take a closer look and work through it together with you if needed.
Thank you for your patience and cooperation.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.