1. 首页 > 科技

Excel如何实现隐藏的内容自动锁定? excel隐藏的列怎么恢复

Excel如何实现隐藏的内容自动锁定?excel隐藏的列怎么恢复

EXCEL如何实现单元格输入内容后自动锁定

 Dim Str As String

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)    '双击运行代码

    Dim Pass, s

    If Target.Cells(1).Value <> "" Then

    Pass = InputBox("请输入修改密码:", "提示")

    If Pass <> "123456" Then

    Application.EnableEvents = False

    Target.Cells(1) = Str

    Application.EnableEvents = True

    MsgBox "密码错误,不能修改", vbOKOnly, "警告"

    Target.Offset(1).Select

    Else

    Target.Cells(1).Select

    

    End If

    End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)   '自动运行代码

Str = Target.Cells(1).Value

End Sub

密码是123456

按ALT+F11切换到VBE窗口,在工程窗口中双击需要锁定的工作表,在右面的窗口中的这段代码粘贴