Hello everyone, thank you in advance for your help.

The weirdest thing is happening to me while trying to code this macro, I am trying to run a forloop to delete worksheets 'numberOfFiles' to 17.

'n...' is a variable which populates from user input. Essentially, the first sheet in this workbook is a collective table of all samples, sheet 2 is a cumulative chart of all samples (stress strain graphs), then sheet 3 is specific information on sample 1, sheet 4 is specific information on sample 2 and so on.

If there is only one sample, then, I want to delete sheets 3 thru 17, if there are 2 samples - 4 thru 17 and so on.

The problem is, when I run this forloop - it deletes all even sheets starting at Sheet4, not every sheet starting at Sheet4.

This, then, throws a subscript out of bounds error. Am I just missing something so simple here in my forloop indexing?

P.S. The second forloop deleting legend entries works fine.

Dim WBT As Workbook ' This Workbook
numberOfFiles = InputBox("Enter Number of Samples to Analyze")
Set WBT = Workbooks("RunCompressionTestingReport.xlsm")

...
Else If numberOfFiles = 2 Then
     With WBT
           For ytu = numberOfFiles + 3 To 17
                Sheets(ytu).Delete
           Next ytu
     End With
     With TotalCht.Chart
           For emg = 15 To numberOfFiles + 1
                .Legend.LegendEntries(emg).Delete
           Next emg
     End With
Else If numberOfFiles = 1 Then
     With WBT
           For ytu = numberOfFiles + 3 To 17
                Sheets(ytu).Delete
           Next ytu
     End With
     With TotalCht.Chart
           For emg = 15 To numberOfFiles + 1
                .Legend.LegendEntries(emg).Delete
           Next emg
     End With
End If