excel - Excel 2010 - 如何从 2 个列表创建验证列表并给它们倾斜
问题描述
如何从 2 个列表中创建 excel 2010 中的验证列表并给它们倾斜?
例如:
Column A:
1 Boys Names
2 Danny
3 Sam
3 Luke
Column B:
1 Girls Names
2 Sarah
3 Ellen
4 Jessica
在 CI 列中,希望能够从 A+B 列中选择“名称”而没有任何依赖关系。我希望能够在下拉列表中看到:
Boys Names
-------------------
Danny
Sam
Luke
Girls Names
--------------------
Sarah
Ellen
Jessica
我不想选择“男孩名字”和“女孩名字”,但只能选择:Danny、Sam、Luke、Sarah、Ellen 或 Jessica。可能吗?
解决方案
对于这样的列表:
男孩名字
----------
丹尼·
萨姆
·卢克女孩名字
---------
莎拉
·艾伦·
杰西卡
您可以在工作表模块中包含以下 VBA 代码:
Private Sub Worksheet_Change(ByVal Target As Range)
Case "Boys Names", "Girls Names", "-----------": 'If the value is one of these options
Target.Clear 'Blank the cell
End Select
End Sub
您可以使用If Target.Value="Boys Names" OR Target.Value="Girls Names"OR Target.Value="-----------" Then
,但Switch
语句更简单、更整洁。您可能还想使用Intersect
来检查目标单元格,以防您在工作表的另一部分需要任何这些值。
推荐阅读
- kubernetes - 如何从 pod 的容器中创建 k8s 集群中的秘密?
- highcharts - 如何使用 Highcharts 消除饼图切片上的间隙
- javascript - 从 React Native 应用程序将 CSV 文件发送到 Express api
- json-ld - JSONLD:如何定义具有不可预测子属性的“杂项”属性?
- powershell - 在 Col C 上分组并在 Col B 上选择 Max 并显示 Col A、B 的 PowerShell 脚本
- arrays - 为什么我在这段代码中有类型错误'(array[True...。任何帮助=
- python - python中的matplotlib.animate使用多处理
- sql-server - T-SQL 谜题:将其用作内联视图时查询失败
- powershell - Powershell文件重命名+日期
- sql - 无法绑定多部分标识符和不明确的列 SQL 错误消息