Excel中的动态下拉列表

时间:2015-05-08 09:46:47

标签: excel

我的数据以这种方式排列:

A
1 ABC 描述1
2 XYZ 描述2
3 MNO 描述3
4 ABC 描述4
5 MNO 描述5

现在在单元格A1的另一个工作表中,应该有一个基于上面A列的下拉列表。点击它ABC,XYZ& MNO将显示在下拉列表中。然后当我在A1中选择ABC时;在B1中,描述(描述1和描述4)都应显示在下拉列表中。

2 个答案:

答案 0 :(得分:0)

I wrote this function which concatenates all matches:

$("img").click(function(){
var top = $(this).offset().top + $(this).width() + 2;
var left = $(this).offset().left - $(this).height() / 2;  
$("#player-popup span").text("Player "+$(this).data("playerid")); 
$("#player-popup").css({ top: top, left: left }).show();

});

And this function to display only the unique values from a range (for the data validation), enter it as an Array Formula + use a dynamic named range. I show how to use them below:

#player-back{
height:250px; 
background:#0F0;
}
#p1{
margin-top:50px;
margin-left:80px;
}
#p2{
margin-left:150px;
}
#p3{
margin-left:200px;
}
#player-popup{
background:orange;
height:27px;
width:85px;
border-radius:10px;
text-align:center;
position:absolute;
}
  1. Enter the formula as shown on the picture below and press CTRL+SHIFT+ENTER:

Enter Formula

  1. Open the name manager with CTRL+F3 and define a dynamic named range with the following formula position:absolute; :

dynamic named range

  1. Use the Dynamic named range as a list for the data validation:

Data Validation with Unique codes

  1. works as expected:

Final Result

Notice : The array formula is not dynamic to the values entered and may need to be updated to match the number of rows when additional rows are added - remember to always press CTRL+SHIFT+ENTER when updating the range.

UDF entered as Array Formula:

UDF entered as Array Formula

答案 1 :(得分:-1)

请检查我的方法:

  1. 无需对数据进行排序
  2. 支持多对多关系
  3. 没有VBA
  4. 没有命名范围
  5. 不需要事先知道独特的物品名称或数量
  6. 在新标签中打开图像以便更好地看待:

    在Sheet1(数据表)中: enter image description here
    作为公式: enter image description here

    在Sheet2(帮助表)中: enter image description here
    作为公式:
    enter image description here

    在Sheet3(结果表)中: enter image description here