我想使用VBA隐藏或取消隐藏单元格(不是工作表,我可以使用Range(,并保护按钮,以便隐藏或取消显示需要密码才能工作。你能帮忙吗?
谢谢!
在buttonclick上调用一个输入框并设置密码,如果正确,请运行代码。
Option Explicit
Private Sub Rectangle1_Click()
Dim pass As String, pass1 As String, x As String ' Set you variables
x = 1 ' Used as a counter for number of tries
pass1 = "abC!23" ' Set you password!
pass = InputBox("Passcode?", "Attempt " + x)' Display and ask for the
'first login attempt
Do While (Not pass = pass1) ' Do while input does NOT match the passcode
x = x + 1 ' Add one attempt
If x > 3 Then Exit Sub ' If there are more than 3 attempts then exit
'the code
pass = InputBox("Wrong passcode, try again", "Attempt " + x + "/3") '
'Reset the pass variabel with another attempt, x keeps tabs on how many
'tries
Loop ' Loop -> return to Do While
MsgBox ("Login succeeded") '<----delete this messagebox if you want and
'-----run your code upon correct pass here-----
结束子