ThisWorkBook.Names().Comment 将引用从 A1 转换为 F1C1

问题描述

向 Microsoft Excel 中 Names 集合中的 Name 添加注释会使 Name 不可用。奇怪的是,它有时会发生,有时不会,但是在使用 F8 逐步运行代码时它会安全地发生。

Option Explicit
'I AM MORE INTERESTED IN UNDERSTANDING THE REASON FOR THE ERROR THAN ALTERNATIVE SOLUTIONS!
Sub test()
    Dim My_Range As Range
    Set My_Range = ActiveSheet.Range("N1:P17")
    ThisWorkbook.Names.Add "DAILY_QUOTES_LME",My_Range.CurrentRegion
    'The following instruction,has a strange behavior,(it happens only sometimes);
    'But it happens safely when running step by step with F8.
    'This next line converts style reference A1 to F1C1 according to the name manager.
    ThisWorkbook.Names("DAILY_QUOTES_LME").Comment = Date 'Tag for update date.
    'The following statement produces an error 424 because the reference Now has an F1C1 style.
    [DAILY_QUOTES_LME].Borders(xlEdgeLeft).Color = 14395790
End Sub

我留下了一些截图: https://drive.google.com/file/d/1elM0RTz92Tr5Ioe05MNq3iyi4ZLY11F4/view?usp=sharing https://drive.google.com/file/d/14Vz854fYcknPZB4GsW5UkG2NSW3lgGob/view?usp=sharing 非常感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)