Skip to content

Commit

Permalink
fix: bug trying to hide all sheets in SheetPicker
Browse files Browse the repository at this point in the history
  • Loading branch information
sha5010 committed Feb 2, 2023
1 parent 1119be5 commit 5768deb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/userforms/SheetPicker.frm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Private Sub Toggle_Sheet_Visible(ByVal n As Integer, _
Dim sheetVisibility As Integer
Dim hiddenText As String
Dim sheetName As String
Dim i As Integer
Dim cnt As Integer

'N番目のシートの可視/不可視状態をトグル
If ActiveWorkbook.Worksheets.Count < n Then
Expand All @@ -59,6 +61,22 @@ Private Sub Toggle_Sheet_Visible(ByVal n As Integer, _

With ActiveWorkbook.Worksheets(n)
If .Visible <> sheetVisibility Then
'check the number of visible sheets
For i = 1 To ActiveWorkbook.Worksheets.Count
If ActiveWorkbook.Worksheets(i).Visible = xlSheetVisible Then
cnt = cnt + 1
If cnt > 1 Then
Exit For
End If
End If
Next i

'not all sheets can be hidden
If cnt = 1 And .Visible = xlSheetVisible Then
MsgBox "すべてのシートを非表示にすることはできません。", vbExclamation
Exit Sub
End If

.Visible = sheetVisibility
sheetName = hiddenText & .Name
Else
Expand Down

0 comments on commit 5768deb

Please sign in to comment.