[英]Comparing two excel sheets and finding max value AND copying neighbor cell
I have two sheets, with similar formatting but different values. 我有两张纸,格式相似但值不同。
Here's an example (real spreadsheet of course has more values) 这是一个示例(实际的电子表格当然具有更多的价值)
Sheet 1 工作表1
Temp | 温度| Year 89 |
89年| 1979
1979年
Sheet 2 工作表2
Temp | 温度| Year 77 |
77年| 1998
1998年
I want to compare the Temp Values and put the highest value in a 3rd sheet, and copy the neighboring year value into the neighboring cell in the 3rd sheet. 我想比较温度值并将最高的值放在第三张纸中,然后将相邻年份的值复制到第三张纸中的相邻单元格中。 So what I have as a result in the 3rd sheet by using this formula: =MAX(Sheet1!B4,Sheet2!B4) is:
因此,使用以下公式,我在第三张纸上得到的结果是:= MAX(Sheet1!B4,Sheet2!B4)是:
89 89
But what I'd like is (by referencing the value in the next column and placing it in next column on 3rd sheet): 但是我想要的是(通过引用下一列中的值并将其放在第三页的下一列中):
89 | 89 | 1979
1979年
Does anyone have an idea how to do this? 有谁知道如何做到这一点?
Thanks for your time, 谢谢你的时间,
S 小号
I would suggest something like: 我建议类似的东西:
=iif(Sheet1!B4 = MAX(Sheet1!B4, Sheet2!B4), Sheet1!C4, Sheet2!C4) = iif(Sheet1!B4 = MAX(Sheet1!B4,Sheet2!B4),Sheet1!C4,Sheet2!C4)
But you will have an issue if the max value is the same for both. 但是,如果两者的最大值相同,则会遇到问题。 Of course you can account for that if it is a possibility and a problem.
当然,如果这是一种可能性和问题,您可以考虑一下。
Actually, that is not a very efficient way of doing this. 实际上,这不是一种非常有效的方法。 This would be better:
这样会更好:
=iif(Sheet1!B4 > Sheet2!B4, Sheet1!C4, Sheet2!C4) = iif(Sheet1!B4> Sheet2!B4,Sheet1!C4,Sheet2!C4)
And what the heck, if you need to have both C column values when the B columns are equal, you would do something like this: 而且,如果在B列相等时需要同时拥有两个C列值,那么您将执行以下操作:
=iif(Sheet1!B4 > Sheet2!B4, Sheet1!C4, iif(Sheet1!B4 = Sheet2!B4, Sheet1!C4 & ", "& Sheet2!C4, Sheet2!C4)) = iif(Sheet1!B4> Sheet2!B4,Sheet1!C4,iif(Sheet1!B4 = Sheet2!B4,Sheet1!C4&“,”&Sheet2!C4,Sheet2!C4))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.