Hi everyone! First time posting here.
I found a VBA script on here that allowed me to copy a Template tab that I have and rename it to whatever I want.
I wanted to take it a step further and add that same name to the next row in my Summary tab.
Below is the VBA. Could someone help with adding the additional code to pull in the new tab name?
Sub NewSite2()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet: Set ws = wb.Sheets("Template")
Dim newws As Worksheet, sh As Worksheet, newname
Dim query As Long, xst As Boolean, info As String
retry:
xst = False
newname = Application.InputBox("Enter a new sheet name.", info, , , , , , 2)
If newname = "False" Then Exit Sub
For Each sh In wb.Sheets
If sh.Name = newname Then
xst = True: Exit For
End If
Next
If Len(newname) = 0 Or xst = True Then
info = "Sheet name is invalid. Please retry."
GoTo retry
End If
ws.Copy after:=ws: Set newws = ActiveSheet: newws.Name = newname
End Sub
Bookmarks