【问题标题】:How to lock a single cell using a macro, but without protecting sheet如何使用宏锁定单个单元格,但不保护工作表
【发布时间】:2017-10-16 15:14:33
【问题描述】:

我希望运行一个宏,该宏将自动填充某些单元格,然后将信息锁定在宏末尾的单元格中,以便其他用户在填充后无法编辑。

有没有办法使用宏保护/锁定单个单元格而不保护工作表?

谢谢

【问题讨论】:

  • 我不知道。我认为您需要保护工作表并解锁所有其他单元格。
  • 嗨菲利普,谢谢!

标签: excel vba


【解决方案1】:

如果您想使用我在评论中的建议使电子表格感觉不受保护,但不适用于感兴趣的单个单元格。

' set cell range you want to be editable.  I used a random range here
Worksheets("yoursheet").Range("A1:G100").Locked = True
' suppose you want B2 locked
Worksheets("yoursheet").Cells(2,2).Locked = True
' protect the sheet
Worksheets("yoursheet").Protect UserInterfaceOnly:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-28
    • 2016-08-14
    • 1970-01-01
    • 2021-11-30
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多