Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
With Selection(1)
If Target = Cells(.Row, 4) Then
If Cells(.Row, 4).Interior.Color = vbBlue Then
Cells(.Row, 4) = "顯示工作表"
Cells(.Row, 4).Interior.Color = vbRed
Worksheets(.Row - 1).Visible = xlSheetVisible
ElseIf Cells(.Row, 4).Interior.Color = vbRed Then
Cells(.Row, 4) = "隱藏工作表"
Cells(.Row, 4).Interior.Color = vbBlue
Worksheets(.Row - 1).Visible = xlSheetVeryHidden
Else
End If
End If
End With
End Sub
複製代碼
作者: 准提部林 時間: 2019-7-24 10:46
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
With Cells(Target(1).Row, 2)
On Error GoTo 999
CK% = Sheets(.Value).Visible + 1
Sheets(.Value).Visible = CK
.Cells(1, 3) = Array("顯示工作表", "隱藏工作表")(CK)
.Cells(1, 3).Interior.Color = Array(vbRed, vbBlue)(CK)
End With
999: End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
With Cells(Target(1).Row, 2)
On Error GoTo 999
ck% = Abs(1 - Sheets(.Value).Visible)
Sheets(.Value).Visible = ck
.Cells(1, 3) = Array("隱藏工作表", "顯示工作表")(ck - 1)
.Cells(1, 3).Interior.Color = Array(vbBlue, vbRed)(ck - 1)
End With
999: End Sub