|
Sub シート隠蔽()
'
Dim ws As Variant
Dim response As Integer
Dim i As Integer
Dim cnt As Integer 'シート数
'
cnt = 0
For Each ws In Sheets
If Sheets(ws.Name).Visible = True Then '表示されているシートの数
cnt = cnt + 1
End If
Next
'
i = 0
For Each ws In Sheets
If Sheets(ws.Name).Visible = True Then
Sheets(ws.Name).Select
i = i + 1
response = MsgBox("シート(" & i & ") 【 " & ws.Name & " 】 を隠しますか?" & Chr$(13) & Chr$(13), _
vbYesNoCancel + vbQuestion + vbDefaultButton2, "確認!")
If response = vbYes Then
If cnt = 1 Then
MsgBox "全てのシートを非表示にする事は出来ません!", vbExclamation
Exit Sub
End If
Sheets(ws.Name).Visible = False
cnt = cnt - 1
Else
If response = vbCancel Then
Exit Sub
End If
End If
End If
Next
'
End Sub
|