[英]Is there a way to scan an entire column based on one cell in another column and pull out a value of the corresponding column?
A一种 | B乙 | C C | D D |
---|---|---|---|
4 4 | 1 1 | 6 6 | 5649 5649 |
3 3 | 8 8 | 10 10 | 9853 9853 |
5 5 | 2 2 | 7 7 | 1354 1354 |
I have two worksheets, for example column A in sheet 1 and columns BD in sheet 2.我有两个工作表,例如工作表 1 中的 A 列和工作表 2 中的 BD 列。
What I want to do is to take one value in Column A, and scan both columns B and C and it is between those two values, then display the corresponding value from column D in a new worksheet.我想要做的是在 A 列中取一个值,然后扫描 B 列和 C 列,它位于这两个值之间,然后在新工作表中显示 D 列中的相应值。
There could be multiple matches for each of the cell in column A and if there is no match, to skip it and not have anything displayed. A 列中的每个单元格可能有多个匹配项,如果没有匹配项,则跳过它并且不显示任何内容。 Is there a way to code this and somehow create a loop to do all of column A?有没有办法对此进行编码并以某种方式创建一个循环来完成 A 列的所有操作? I tried using this formula, but I think it only matches for each row and not how I want it to.我尝试使用这个公式,但我认为它只匹配每一行,而不是我想要的。
=IF(AND([PQ.xlsx]Sheet1!$A2>=[PQ.xlsx]Sheet2!$B2,[PQ.xlsx]Sheet1!$A2<[PQ.xlsx]Sheet2!$C2),[PQ.xlsx]Sheet2!$D$2,"")
How do I do this?我该怎么做呢?
Thank you.谢谢你。
I'm not positive if I understood exactly what you intended.如果我完全理解你的意图,我并不肯定。 In this sheet, I have taken each value in A:A and checked to see if it was between any pair of values in B:C, and then returned each value from D:D where that is true.在这张表中,我取了 A:A 中的每个值,并检查它是否在 B:C 中的任何一对值之间,然后从 D:D 返回每个值,其中为真。 I did keep this all on a single tab for ease of demonstration, but you can easily change the references to match your own layout.为了便于演示,我确实将所有这些都保存在一个选项卡上,但您可以轻松更改引用以匹配您自己的布局。 I tested in Excel and then transferred to this Google Sheet, but the functions should work the same.我在 Excel 中测试,然后转移到这个 Google Sheet,但功能应该是一样的。
https://docs.google.com/spreadsheets/d/1-RR1UZC8-AVnRoj1h8JLbnXewmzyDQKuKU49Ef-1F1Y/edit#gid=0 https://docs.google.com/spreadsheets/d/1-RR1UZC8-AVnRoj1h8JLbnXewmzyDQKuKU49Ef-1F1Y/edit#gid=0
=IFERROR(TRANSPOSE(FILTER($D$2:$D$15, ($A2>=$B$2:$B$15)*($A2<=$C$2:$C$15))), "")
So what I have done is FILTEREDed column D on the two conditions that Ax is >= B:B and <= C:C, then TRANSPOSED the result so that it lays out horizontally instead of vertically, and finally wrapped it in an error trap to avoid #CALC where there are no results returned.所以我所做的是在 Ax 是 >= B:B 和 <= C:C 的两个条件下对列 D 进行过滤,然后对结果进行 TRANSPOSED 使其水平而不是垂直布局,最后将其包裹在错误陷阱中避免没有结果返回的#CALC。
I added some random data to test with.我添加了一些随机数据进行测试。 Let me know if this is what you were looking at, or if I misunderstood your intent.如果这就是您所看到的,或者我是否误解了您的意图,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.