英文:
Creating a Dependent Drop-Down List where the VALUES (not just the list) come from an INDIRECT Function
问题
以下是翻译好的部分:
我们公司使用的软件利用SpreadsheetGear来构建估算的仪表板。来自我们估算软件的数据被输入到此仪表板的一个工作表中,我构建我的公式以从该工作表中读取内容。
SpreadsheetGear的限制在于它没有像UNIQUE或SORT这样的新颖的数组公式。
我试图做的是,有一个下拉列表,另一个单元格可以读取它,使用名称调用其中四个列表之一。这是一个标准的依赖下拉列表,通过数据验证实现,并在源中引用只能输出命名范围的单元格。
问题出在,当我不使用已命名的范围(其中名称只是对范围的引用)时,我想使用间接函数来调用此范围的缩写版本。
例如
我可以在单元格A1中从列表中选择一个列表:List1,List2,List3。
然后在单元格B1中,我想生成一个下拉列表,基于我在A1中选择的内容。
List1在C1:C100中,但只有8个值被填充。因此,我有另一个单元格使用一些公式来找出最后一个非空单元格,在D1中生成文本值"$C$1:$C$9"。
如果我只是在“引用”中使用“=$C$1:$C$100”作为已命名范围,Excel允许我使用这个依赖下拉列表。但我的依赖下拉列表有100个值。
如果不使用已命名范围,而使用"=INDIRECT(D1)",Excel将不允许我使用下拉列表。
目标是,如果只有8个值被填充,我只希望我的下拉列表有8个值,但随着通过估算软件添加更多值,它可以扩展。
使用间接来调用名称中的文本"范围引用",然后在数据验证列表源中引用该名称,似乎太复杂。但我想把这个问题提出来,看看是否有人可以帮助我。
或者,如果有一种方法可以过滤掉空白(我尝试在名称中使用OFFSET以及已命名范围,但没有取得多少成功)。
我尝试过在名称和数据验证中都使用INDIRECT,只在第一个中使用INDIRECT而不是第二个,在第二个中使用INDIRECT而不是第一个。
英文:
The software our company uses utilizes SpreadsheetGear to build dashboards for Estimating. The data from our estimating software is fed into a sheet into this dashboard, and I build my formulas to read things from that sheet.
The limitation with SpreadsheetGear is that it doesn't have any of the fancy new array formulas like UNIQUE or SORT.
What I am trying to do, is have a drop-down list which can be read by another cell, which calls up one of four lists using Names. This is a standard dependent drop-down list, and is achieved using Data Validation and in the Source, referencing a cell that can only output named ranges.
The issue comes when instead of using Named Ranges (where the names are just references to a range), I want to use an indirect function to call up a shortened version of this range.
For example
I can pick from a List from a List in cell A1: List1,List2,List3.
Then in cell B1 I want to generate a dropdown list based on what I picked in A1.
List1 is in C1:C100, but only 8 values are filled. So I have another cell which uses some formulas to figure out the last non-blank cell, and in D1 I generate the text value "$C$1:$C$9".
If I just use =$C$1:$C$100 in the 'Refers to' as a Named Range, excel allows me to use this dependent drop-down list. But my dependent drop-down list is 100 values long.
If instead of a named range I use "=INDIRECT(D1)" excel won't allow me to use the drop-down list.
The goal is I only want my dropdown list to be 8 values if only 8 values are filled, but expand more as more values are added through the estimating software.
It seems like using INDIRECT to call a text "range reference" in a Name, and then using another INDIRECT in the data validation list source to reference said Name is too much. But I want to open this problem up to the floor to see if anyone can give me a hand on it.
Alternatively, if there is a way to filter out the blanks (I've tried OFFSET within the Name along with the named range, without much success.)
I've tried putting INDIRECT to both the Name and the Data Validation, INDIRECT to the first but not the second, INDIRECT to the second but not the first.
答案1
得分: 1
I'll provide the Chinese translation for the content you provided:
进一步编辑
我将简化为仅限2个范围,以保持简单,但将其扩展为所请求的4个(或更多)将很简单。
按照我在下面原始帖子中描述的方式定义动态范围(List1、List2)。在这里,我已经定义了List1为C1:C100
,List2为D1:D100
。
在A5
的数据验证对话框中,使用此公式(A2
中的选择告诉Excel在A5
的下拉菜单中使用哪个Indirect
语句):
=CHOOSE($A$2, INDIRECT(List1), INDIRECT(List2))
在A2
中选择要使用的验证列表的编号(选择1表示List1,依此类推)。然后该列表将用于A5
的验证。图片显示:
- 左侧:在
A2
中选择列表 - 中间:基于List1在
A5
中的验证 - 右侧:基于List2在
A5
中的验证
如果您需要在A2
中显示实际列表名称而不是它们的编号,这是可能的,但这将增加复杂性。首先让我们使其按照期望的方式工作。
原始内容(主要)
您可以使用动态范围来完成这个任务。这有点令人困惑,但请跟着我走。
首先,定义范围。如果List1位于Sheet1的C1:C100
中,请在新名称对话框中插入以下公式:
"Sheet1!$c$1:$c$" & COUNTA(Sheet1!c1:c100)
COUNTA()
确定了范围中的最后一行(条目必须位于连续的行中,否则将失败)。
英文:
Further Edit
I'll limit this to 2 ranges to keep it simple, but extending it to the 4 requested (or more) would be trivial.
Define the dynamic ranges (List1, List2) as described in my original post below. Here I've defined List1 as C1:C100
and List2 as D1:D100
.
In the Data Validation dialog for A5
, use this formula (the selection in A2
tells Excel which Indirect
statement to use for the drop-down in A5
):
=CHOOSE($A$2, INDIRECT(List1), INDIRECT(List2))
Select the number of the validation list to use (select 1 for List1, etc.) in A2
. That list is then used for validation in A5
. The picture shows:
- Left: choose the list in
A2
- Center: validation based on List1 in
A5
- Right: validation based on List2 in
A5
If you need the actual list names in A2
instead of their number, that's possible but it's a further complication. Let's get this working as desired first.
Original (mostly)
You can do this with dynamic ranges. It's a bit confusing, but bear with me.
First, define the range. If List1 is in C1:C100
on Sheet1, insert this formula in the New Name dialog:
"Sheet1!$c$1:$c$" & COUNTA(Sheet1!c1:c100)
The COUNTA()
determines the last row in the range (the entries must be in contiguous rows or this will fail).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论