你如何让一个范围返回它的名字? [英] How do you get a Range to return its Name?

查看:22
本文介绍了你如何让一个范围返回它的名字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim sampleRange as Range
Set sampleRange = Worksheet.Range(Cells(1,1),Cells(1,4)
sampleRange.Name = "Range1"
MsgBox sampleRange.Name

上面的代码将显示范围的实际地址,而不是名称.为什么?
如何获取命名范围以返回其名称?

The above code will show the actual address of the range, not the name. Why?
How do I get a named range to return its name?

推荐答案

对于一个 Range,Name 不是一个字符串,它是一个 Name 对象,然后你使用 Name 属性来获取字符串:

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

这篇关于你如何让一个范围返回它的名字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆