Sub RemoveSheets()
Dim mySheet As Worksheet
Application.DisplayAlerts = False
Workbooks.Add
Worksheets("Sheet2").Select
For Each mySheet In Worksheets
ActiveWindow.SelectedSheets.Delete
Next mySheet
End Sub
Sub IsSuchSheet()
Dim mySheet As Worksheet
Dim counter As Integer
counter = 0
For Each mySheet In Worksheets
If mySheet.name = "Sheet2" Then
counter =counter + 1
End If
Next mySheet
If counter = 1 Then
MsgBox "This workbook contains Sheet2."
Else
MsgBox "Sheet2 was not found."
End if
End Sub
Sub EarlyExit()
Dim myCell As Range
For Each myCell in Range("A1:H10")
If myCell.Value = "" Then
myCell.Value = "empty"
Else
Exit For
End If
Next myCell
End Sub
更多建議: