gpt4 book ai didi

excel - 运行时错误 '1004'无法设置Range类的NumberFormat属性

转载 作者:行者123 更新时间:2023-12-03 03:16:34 25 4
gpt4 key购买 nike

我安装了一个非常简单的命令按钮来为选定的单元格添加时间戳。命令按钮工作完全正常,直到我保护工作表,然后它会抛出标题中提到的错误。我已经检查过单元格的格式未选择为“锁定”。

Private Sub CommandButton1_Click()
Dim ts As Date

With Selection

.Value = Now

.NumberFormat = "h:mm AM/PM"

End With
End Sub

最佳答案

允许格式化单元格

您必须允许设置单元格格式。

enter image description here

或在 VBA 中

ActiveSheet.Protect AllowFormattingCells:=True

关于excel - 运行时错误 '1004'无法设置Range类的NumberFormat属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53418038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com