How do you get a Range to return its Name?

笑着哭i 提交于 2019-11-26 22:57:46

For a Range, Name isn't a string it's a Name object, that you then take the Name property of to get the string:

MsgBox sampleRange.Name.Name

sampleRange.Name = "Range1" to name the range is poor practice

It only works because Name (the string containing "The Name") is the default property of Name.

Much better sampleRange.Name.Name = "Range1"

It's never good practice to use the default property without referring to it explicitly.

Good programming exactly controls the environment by referring explicitly to the property required.

Removes ambiguity as created the issue here. Eliminates the issue created if the default property is changed in a future update.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!