Hello,

So I have a span of worksheets within a workbook, each name is in the format of "20 _______" except the first of the set, which is just "20"
I want to copy this set of sheets, in order, and rename them based on the operation number the user puts in - so the next set should be 30.

Currently, I get all the worksheets copied to the end of the sheets, which is correct, and the first sheet copied is correctly renamed, but the other sheets are not remained - they just get assigned "20 ______ (2)"

I have also tried using
ws.Name
instead of
ActiveSheet.name
in the For Each/If loop, but that didn't work

Here's the code:

Public Sub AddNewOp()
    Dim opNum As Integer
    Dim ws As Worksheet, flg As Boolean

    On Error Resume Next
    opNum = InputBox("Enter the operation number")
 
    On Error Resume Next
    If opNum <> "" And IsNumeric(opNum) Then
        For Each ws In Sheets
            If ws.Name Like "*20*" Then
                ws.Copy After:=Worksheets(Sheets.Count)
                ActiveSheet.Name = opNum
                Range("G1") = opNum
            End If
        Next
    End If

End Sub