本文介绍了[VBA]向新创建的名称对象添加注释会扭曲名称对象中的所有引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 您好 创建名称对象后 并将有效公式(在xlA1中)分配给RefersTo,添加注释会将所有引用子项重置为不严格遵循A1语法的相同字符串。因此,添加注释会扭曲刚刚定义的名称对象的引用。 我在这里遗漏了什么或者可能是错误吗? Sub TestNameObjectWithComment() Dim nm As Name Dim sName As String Dim sRefersTo As String sName ="测试" sRefersTo =" = Data!$ A $ 1" 设置nm = ThisWorkbook.Names.Add(名称:= sName,RefersTo:= sRefersTo) Debug.Print nm.RefersTo'打印:=数据!$ A $ 1 nm.Comment ="我的评论" Debug.Print nm.RefersTo'打印:=数据!Z1S1(德语区域设置),无效的A1语法 结束次级许多谢谢, J。 使用Win10 / Excel2016 解决方案 您好, 这是讨论Microsoft Excel问题和反馈的论坛,我会将您的问题转到MSDN论坛Excel https://social.msdn。 microsoft.com/Forums/en-US/home?forum=exceldev 我们建议适当发布的原因是您将获得最合格的受访者群体,以及其他定期阅读论坛的合作伙伴可以分享他们的知识,也可以从与我们的互动中学习。感谢您的理解。 HiAfter creating a name object and assigning a valid formula (in xlA1) to RefersTo, adding a comments resets all refersto sub-items to the same string which does not strictly follow the A1 syntax. Thus adding the comment distorts the references of the just defined name object.Am I missing something here or is that possibly a bug?Sub TestNameObjectWithComment() Dim nm As Name Dim sName As String Dim sRefersTo As String sName = "Test" sRefersTo = "=Data!$A$1" Set nm = ThisWorkbook.Names.Add(Name:=sName, RefersTo:=sRefersTo) Debug.Print nm.RefersTo ' prints: =Data!$A$1 nm.Comment = "My comment" Debug.Print nm.RefersTo ' prints: =Data!Z1S1 (German locale), invalid A1 syntaxEnd SubMany thanks,J.Working on Win10/Excel2016 解决方案 Hi,This is the forum to discuss questions and feedback for Microsoft Excel, I'll move your question to the MSDN forum for Excelhttps://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldevThe reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding. 这篇关于[VBA]向新创建的名称对象添加注释会扭曲名称对象中的所有引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 16:15