The code i have is to copy a template, ask the user for the sheet name and some data.
All this works fine however the next part of the code is to hide some rows and this always happens on the template rather than the new sheet.
Does anyone see what the issue is with the code as to why this is happening?
All this works fine however the next part of the code is to hide some rows and this always happens on the template rather than the new sheet.
Does anyone see what the issue is with the code as to why this is happening?
Code:
Public Sub CopySheetAndRename() Dim newName As String
On Error Resume Next
newName = InputBox("Enter the sheet name")
Data = InputBox("Enter Data")
If newName <> "" Then
Sheets("Template").Copy After:=Worksheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = newName
Worksheets(newName).Range("C3") = newName
Worksheets(newName).Range("C5") = Data
Worksheets(newName).Activate
End If
Application.ScreenUpdating = False
Application.Calculation = xlManual
For Each c In Worksheets(newName).Range("D5:D53")
If c.Value = "x" Then Rows(c.Row).Hidden = True
Next
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub