|
こんばんは、みなさん。
つんさんとKeinさんのコードをお借りして
'====================================================
Sub main()
Dim SAry() As String
Dim stt As Long
Dim edd As Long
Dim Eidx As Long
Dim Hidx As Long
Dim retcode As Long
On Error Resume Next
retcode = 0
Eidx = Worksheets("E").Index
If Err.Number <> 0 Then retcode = 1
Hidx = Worksheets("H").Index
If Err.Number <> 0 Then retcode = 1
If retcode = 0 Then
stt = WorksheetFunction.Min(Eidx, Hidx)
edd = WorksheetFunction.Max(Eidx, Hidx)
For i = stt + 1 To edd - 1
ReDim Preserve SAry(stt To i - 1)
SAry(i - 1) = Worksheets(i).Name
Next i
If edd > stt + 1 Then
Application.DisplayAlerts = False
Worksheets(SAry()).Delete
Application.DisplayAlerts = True
End If
Else
MsgBox "「E」 又は 「H」というシート名がありません"
End If
End Sub
試してみて下さい
|
|