返回列表 上一主題 發帖

隱藏按右鍵的-取消隱藏功能

回復 1# myleoyes
指定工作表中:  當滑鼠 選擇有欄隱藏的範圍時 按右鍵的 隱藏功能,取消隱藏
  1. Dim A As CommandBarControls, B As CommandBarControls
  2. Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
  3.     Dim Msg As Boolean, C As Range
  4.     Msg = True
  5.     For Each C In Target.Columns
  6.         If C.EntireColumn.Hidden Then
  7.             Msg = False
  8.             Exit For
  9.         End If
  10.     Next
  11.     功能表 Msg
  12. End Sub
  13. Private Sub Worksheet_Deactivate()
  14. 功能表 True
  15. End Sub
  16. Private Sub Worksheet_SelectionChange(ByVal T As Range)
  17.    功能表 True
  18.    Select Case T(1).Address(0, 0)
  19.      Case "A1"
  20.        [E1] = "=Sheet2!B1"
  21.        Dim hwd As Long
  22.        lTimeID = timeSetEvent(10, 0, AddressOf TimeProc, 1, 1)
  23.        zz = InputBox("請輸入密碼", "非經許可請勿開啟以免干擾程式運作")
  24.        [E2] = zz
  25.        If [E1] = [E2] Then
  26.        參照欄
  27.        Else: MsgBox "密碼錯誤!": [E1] = 0: [E2] = "": [E:L].EntireColumn.Hidden = True
  28.        End If
  29.     End Select
  30. End Sub
  31. Private Sub 功能表(T As Boolean)
  32.     Dim E As CommandBarControl
  33.     Set A = Application.CommandBars.FindControls(ID:=886)   '886   隱藏(&H)
  34.     Set B = Application.CommandBars.FindControls(ID:=887)   '887   取消隱藏(&U)
  35.     For Each E In A
  36.         E.Enabled = T
  37.     Next
  38.     For Each E In B
  39.         E.Enabled = T
  40.     Next
  41. End Sub
複製代碼
功能 停止使用

TOP

        靜思自在 : 自己害自己,莫過於亂發脾氣。
返回列表 上一主題