通过双条件填充列表
我有兴趣实施一些东西,但我不确定它是否可能,并且希望您能参与其中。
这是我的场景:
我将有两个验证单元,它们将显示为我将从中进行选择的列表。 这些是我想要满足的条件并从数据库中删除我的列表。
我有一个要抛出 B13:B23 的特工列表,接下来的两个我有数据列 假设我的数据库看起来像这样
B C D E
X | Y | Z
agent1 1 | 1 | 0
agent2 0 | 1 | 0
agent3 0 | 1 | 1
agent4 1 | 0 | 0
...
当我从验证单元格1:X和验证单元格2:1中选择时,我想从B列填充代理名称列表。 它应该只显示
column:
agent1
agent4
X 列中带有 0 的或代理...
我在某处读过有关数组公式的内容,但我不知道这是否方便,不幸的是我没有任何宏背景:(但我知道在 C++ 中这样的东西相当容易 ,
预先感谢
im interested to implement something but im not sure if it would be possible and would like your intake on it.
here is my scenario:
i will have two validation cells which will be shown as List that I will pick from.
those are my condition that i would like to meet and ommit my list from a database.
I have a list of agents going threw B13:B23 and next two them i have columns of data
assuming that my data base looks like this
B C D E
X | Y | Z
agent1 1 | 1 | 0
agent2 0 | 1 | 0
agent3 0 | 1 | 1
agent4 1 | 0 | 0
...
i want to populate a list of agent name from column B, when i select from the validation cell1: X and validation cell2: 1.
it should show only
column:
agent1
agent4
or agents in column X with 0...
i read somewhere about array formula but i dont know if this is convenient and i unfortunately dont have any background in macros:( but i know in C++ something like this is fairly easy with conditional statements.
thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是可能的。解决此问题的一种方法是,每当 Worksheet_Change 中的目标与验证单元格 1 或单元格 2 相交时,调用一个列出相关代理的子程序 -> 。验证发生了变化。
然后,您将运行一个具有 3 个参数 srcRange、validationColumn 和validationValue 的子程序,该子程序遍历 srcRange 的每一行,并检查位置 rownumber、validationColumn 上的单元格是否等于validationValue,如果是,则输出代理并设置 outputrow + 1
将此 VBA 放入你的工作表:
我在你的例子上测试了它并且它有效。
It is possible. One way to approach this is to call a sub that lists you the relevant agents whenever the Target in your Worksheet_Change intersects with validation cell1 or cell2 -> the validation changed.
Then you would run a sub with 3 paramenters srcRange, validationColumn and validationValue that goes throgh each row of srcRange and checks if the cell on position rownumber, validationColumn is equal to validationValue if so it outputs the agent and sets outputrow + 1
Put this VBA in your Sheet:
I tested it on your example and it worked.