简体   繁体   中英

Return the sheet name of a dynamic name range in vba

I have the following problem:

I have a dynamic namerange named TestDym .

I am trying to retrieve the name of the worksheet that this namerange belongs through vba.

I know that you can only refer to a namerange with the following structure:

Range("TestDym")

However, I cannot get the sheet name of this namerange.

Is it possible?

Regards

Thanasis

Range("TestDym").Worksheet.Name

If you wish to return the "Scope" of the name range, you can use:

Names("TestDym").Parent.Name
  • If TestDym is a workbook level name, then the result will return the workbook name.
  • If TestDym is a worksheet level name, then the result will return the worksheet name.

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

这将为您提供您所在范围的工作表的名称。

Range("TestDym").Parent.Name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM