[英]Reference Dynamic Named Range dependent on cell value Excel
I am trying to dynamically reference a name range based on the contents of a cell.我正在尝试根据单元格的内容动态引用名称范围。
For example, I have the following dynamic named ranges:例如,我有以下动态命名范围:
tCat1_Pass
tCat2_Pass
tCat3_Pass
Assuming we have the value 2 in Cell A1, I would like to reference tCat2 like the following假设我们在单元格 A1 中有值 2,我想像下面这样引用 tCat2
"tCat"&A1&"_Pass" which would = "tCat2_Pass"
INDIRECT doesn;t work with this, are there any other solutions, apart from writing a UDF or using CHOOSE? INDIRECT 不起作用,除了编写 UDF 或使用 CHOOSE 之外,还有其他解决方案吗?
I have solved this by writing a small UDF:我通过编写一个小的 UDF 解决了这个问题:
Public Function nm_return(cat_nbr As Integer, tbl_nm As String)
nm_return = Range("tCat" & cat_nbr & tbl_nm)
End Function
You can also use EVALUATE
within Name Manager, ie define nm_return as:您还可以在名称管理器中使用
EVALUATE
,即将 nm_return定义为:
=EVALUATE("tCat"&$A$1&"_Pass")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.