返回列表 上一主題 發帖

請教一個sheets單個加密的問題, 煩請大大賜教

本帖最後由 GBKEE 於 2011-12-23 18:30 編輯

回復 10# joychiangg
加入ThisWorkbook 的預設事件
  1. Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
  2.     If Sh.Name <> "Sheet1" Then
  3.         Sh.Cells.Interior.ColorIndex = 2
  4.         Sh.Cells.Font.ColorIndex = 2
  5.     End If
  6. End Sub
複製代碼

TOP

本帖最後由 Hsieh 於 2011-12-23 23:59 編輯

回復 10# joychiangg
刪除所有工作表模組內的程序
Thisworkbook模組
  1. Private Sub Workbook_Open()
  2.     Sheets("sheet1").Select
  3. End Sub

  4. Private Sub Workbook_SheetActivate(ByVal Sh As Object)
  5. NoData Sh.Name
  6. End Sub
複製代碼
一般模組
  1. Sub NoData(sht As String)
  2. With Sheets(sht)
  3. If sht = "Sheet1" Then Exit Sub
  4.    .Cells.Font.ColorIndex = 2
  5.    .Cells.Interior.ColorIndex = 2
  6.    pwd = Application.InputBox("請輸入密碼:")
  7.    Select Case sht
  8.    Case "中山"
  9.    p = 40
  10.    Case "東台北"
  11.    p = 13
  12.    Case "建北"
  13.    p = 48
  14.    End Select
  15. If pwd = CStr(p) Or pwd = 6309 Then
  16. Range("A1").Select
  17. Cells.Interior.ColorIndex = xlNone
  18. .Cells.Font.ColorIndex = xlColorIndexAutomatic
  19. Else
  20. MsgBox "輸入錯誤,請從新選擇!!"
  21. Sheets("sheet1").Select
  22. End If
  23. End With
  24. End Sub
複製代碼
學海無涯_不恥下問

TOP

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