I have some VBA code which copy a speardsheet and then delete it.
Private Sub CommandButton1_Click()
Sheets("Sheet1").Copy Before:=Sheets(1)
Dim i As Integer
i = 1
Do While (i <= Sheets.Count)
If Sheets(i).Name = "Sheet1" Then
i = i + 1
Else
Application.DisplayAlerts = False
Sheets(i).Delete
Application.DisplayAlerts = True
End If
Loop
End Sub
However, when I test this, it halts with the error message "Can't
enter break mode at this time", with options Continue,End,Help and
the usual Debug button is greyed out.
If I select 'Continue', all the sheets except "Sheet1" will be
deleted as I desired.
If I select 'End',the current spreadsheet is deleted but I can't
procede with any more code in the subroutine.
Any one can help me on this problem? ‚hwant to find the problem of
the codes, or add some codes to select 'Continue' automatically so
that user will not see the popup msg.