The script works fine, but every time I exit the workbook I get the following run-time error:
Run-Time error '1004':
Method 'Worksheets' of object '_Global' failed

I have attached the code for the sub that is causing the error. It occurs on the first line of the first "If" statement. Any help would be appreciated.

Private Sub TestSpeed_Change()

Dim i As Integer

    If Worksheets("Parameters").Range("Test_Speed_Run") = "1" Then
    Worksheets("Input").CatalogBy.Enabled = True
    Else
    Worksheets("Input").CatalogBy.Enabled = False
    End If
    
    If Worksheets("Parameters").Range("Test_Speed_Run") = "2" Then
        With Worksheets("Input").Range("TestSpeedFormat")
                .Locked = False
                .Interior.Color = RGB(255, 255, 153)
        End With
    Else
        For i = 1 To Range("TestSpeedFormat").Count
        Range("TestSpeedFormat")(i).Formula = "=Data_TestSpeed"
        Next i
        With Worksheets("Input").Range("TestSpeedFormat")
                .Locked = True
                .Interior.Color = RGB(221, 221, 221)
        End With
    End If

End Sub