也就是每次点击各个工作表时,默认什么内容都没有,会弹出密码输入框,输入正确后才能看到
第1个回答 2015-03-05
在工作表模块下定义事件如下:
Private Sub Worksheet_Activate()
If InputBox("please input password here:") = "password" Then
Me.Unprotect "password"
Me.Cells.EntireColumn.Hidden = False
End If
End Sub
Private Sub Worksheet_Deactivate() '离开时隐藏所有列并保护工作表
On Error Resume Next
Me.Cells.EntireColumn.Hidden = True
Me.Protect "password"
End Sub
Private Sub Worksheet_Activate()
If InputBox("please input password here:") = "password" Then
Me.Unprotect "password"
Me.Cells.EntireColumn.Hidden = False
End If
End Sub
Private Sub Worksheet_Deactivate() '离开时隐藏所有列并保护工作表
On Error Resume Next
Me.Cells.EntireColumn.Hidden = True
Me.Protect "password"
End Sub
第2个回答 2015-03-05
禁用 宏将失效
在 sheet1 sheet2 添加
Private Sub Worksheet_Activate()
ActiveSheet.ScrollArea = "a1:a1"
ActiveWindow.Zoom = 10
If Application.InputBox("查看密码", , ***) = 123 Then
Cells(1, 1).Select
ActiveSheet.ScrollArea = "a1:xfd1048576"
ActiveWindow.Zoom = 85
Else
MsgBox "错误,工作表将隐藏"
ActiveSheet.Visible = 0
End If
End Sub追问
在 sheet1 sheet2 添加
Private Sub Worksheet_Activate()
ActiveSheet.ScrollArea = "a1:a1"
ActiveWindow.Zoom = 10
If Application.InputBox("查看密码", , ***) = 123 Then
Cells(1, 1).Select
ActiveSheet.ScrollArea = "a1:xfd1048576"
ActiveWindow.Zoom = 85
Else
MsgBox "错误,工作表将隐藏"
ActiveSheet.Visible = 0
End If
End Sub追问
这一条【If Application.InputBox("查看密码", , ***) = 123 Then】编译错误
追答If Application.InputBox("查看密码", , 0) = 123 Then
123 是密码 ,还有留1张不要密码的表
第3个回答 2020-10-04
Excel如何做到工作表切换要密码才显示其中内容