I have a list of worksheets and want to delete the last X worksheets as listed in column B in worksheet(1). Also, I get an error the first time I run this code but not the second time.
Private Sub sbDeleteSheets()
'Number of sheets to keep
N = 3
'Stopping Application Alerts
Application.DisplayAlerts = False
'delete previously named sheets
For i = N + 1 To Sheets.Count
Sheets(i).Delete
Next i
'Clear spreadsheet names
'Columns("A" & N ":A").EntireColumn.ClearContents
'Enabling Application alerts
Application.DisplayAlerts = True
End Sub
Bookmarks