简体   繁体   English

从级联(从属)下拉列表中删除空白

[英]Remove Blanks from cascading (dependent) drop-down list

So I've got a table with two drop-down lists;所以我有一个带有两个下拉列表的表格; the first is a drop-down list of categories, the second is a list of projects within those categories.第一个是类别的下拉列表,第二个是这些类别中的项目列表。 The way it works is simple: you pick a category, and then the second list gives you the appropriate projects.它的工作方式很简单:您选择一个类别,然后第二个列表为您提供合适的项目。 The lists are based on this table:列表基于此表:

在此处输入图片说明

The problem I'm facing is that the number of projects in each category isn't the same, so while it works fine for categories like Graphic Design (Column D), the list for categories like 3D animation (Column B) are filled with blank spaces.我面临的问题是每个类别中的项目数量不相同,因此虽然它适用于平面设计(D 列)等类别,但 3D 动画(B 列)等类别的列表中充满了空格。

Is there any simple way of getting rid of the spaces?有没有简单的方法来摆脱空间?

Ideally by having excel ignore blanks, because we add new projects from time to time, so Id like the range to stay the same, and not have to fiddle with it too much when adding new projects.理想情况下,通过让 excel 忽略空白,因为我们不时添加新项目,所以我希望范围保持不变,并且在添加新项目时不必过多地摆弄它。

Thanks :)谢谢 :)

Here is a simplified illustration on one way to achieve what you want.这是实现您想要的一种方法的简化图。 Note I am applying this in Sheet2.注意我在 Sheet2 中应用它。

Let's assume that your lists are in a table called Table1.假设您的列表位于名为 Table1 的表中。

Let's assume that your initial dropdown is in E2, and that options must correspond with the header names in Table1.假设您的初始下拉列表在 E2 中,并且该选项必须与表 1 中的标题名称相对应。

Firstly we will create a name called DepDD_All , as follows:首先,我们将创建一个名为DepDD_All的名称,如下所示:

=INDEX(Table1,0,MATCH(Sheet2!$E$2,Table1[#Headers],0))

This will generate a sub-list for your dependent dropdown, including blank lines.这将为您的依赖下拉列表生成一个子列表,包括空行。

To create lists based only on the actual line count, I will use a secondary name, called DepDD_Dyn , as follows:要仅根据实际行数创建列表,我将使用一个名为DepDD_Dyn的辅助名称,如下所示:

=INDEX(DepDD_All,1,1):INDEX(DepDD_All,COUNTA(DepDD_All),1)

Reference this name in your dropdown to display only lists with relevant number of items.在下拉列表中引用此名称以仅显示具有相关项目数量的列表。

依赖下拉菜单

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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