解锁 Excel 中按单元名称 Office 2007 选择的单元格范围

发布于 2024-09-18 04:06:03 字数 523 浏览 2 评论 0原文

我有 3 个单元格,它们相互合并并使用给定的单元格名称(例如“foo”)进行引用。

我现在想使用 locked 属性解锁这些单元格。

以下代码中的锁定将不起作用,但该值将成功分配给单元格:

Workbooks(loadedSheetName).Worksheets("foo").Range("bar").Locked = False
Workbooks(loadedSheetName).Worksheets("foo").Range("bar") = "foo value"

有效的是通过“坐标”引用单元格,但这对我来说并不是一个真正的选择:

Workbooks(loadedSheetName).Worksheets("foo").Range("B3:E3").Locked = False

有吗是否可以按名称选择一些合并单元格并将 locked 属性设置为 false?

I have 3 cells which are merged with each other and are referenced to with a given cellname (for example "foo").

I now want to unlock these cells with the locked attribute.

The lock in the following code will not work, but the value will be successfully assigned to the cell:

Workbooks(loadedSheetName).Worksheets("foo").Range("bar").Locked = False
Workbooks(loadedSheetName).Worksheets("foo").Range("bar") = "foo value"

What will work is referencing the cells by "coordinates" but is not really an option for me:

Workbooks(loadedSheetName).Worksheets("foo").Range("B3:E3").Locked = False

Is there any possibility to select some merged cells by name and set the locked attribute to false?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

灵芸 2024-09-25 04:06:03

以下代码在我的 Excel 2007


Sub aa()
    Dim ce As Range
    Application.ScreenUpdating = False ''# screen flicker off
    ActiveSheet.Unprotect Password:=""
    For Each ce In Range("rng")
        ce.MergeArea.Locked = "False"
    Next ce
    ActiveSheet.Protect Password:=""
End Sub

HTH 中运行正常!

The following code works OK in my Excel 2007


Sub aa()
    Dim ce As Range
    Application.ScreenUpdating = False ''# screen flicker off
    ActiveSheet.Unprotect Password:=""
    For Each ce In Range("rng")
        ce.MergeArea.Locked = "False"
    Next ce
    ActiveSheet.Protect Password:=""
End Sub

HTH!

九八野马 2024-09-25 04:06:03

您不需要遍历 Range 中的每个单元格。

简单地...

 Range("myRangeName").Select
 Selection.Locked = False

You don't need to go through every cell in a Range.

Simply...

 Range("myRangeName").Select
 Selection.Locked = False
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文