简体   繁体   English

比较两个Excel工作表并找到最大值并复制相邻单元格

[英]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.

相关问题 Excel / VBA比较两列并将单元格内容从第三列复制到两张不同工作表中的第四列 - Excel/VBA Comparing two columns and copying the cell contents from a third column into a fourth column in two different sheets 根据单元格值将行从两个或多个Excel工作表复制到另一个 - Copying rows from two or more Excel sheets to another based on cell value VBA比较然后复制两个不同的工作表 - Vba comparing then copying two different Sheets Excel VBA根据唯一值比较两张纸 - excel vba comparing two sheets based on unique value EXCEL 使用 INDEX 和 MAX 计算最大值时查找单元格文本 - EXCEL Finding a cell text when calculating a Maximum value with INDEX and MAX 在与Excel中的最大值关联的另一列中查找单元格 - Finding cell in another column associated with max value in Excel Excel,根据条件在工作表之间复制单元格 - Excel, copying cell between sheets based on criteria excel:比较两个单元格的值,并在另一个单元格中设置值 - excel: comparing the value of two cells, and set the value in another cell 查找两张 excel 工作表的差异 - Finding differences in two excel sheets 比较两张纸的三列,如果发现第一张纸的第四列与第二张纸的复印值匹配 - Comparing 3 columns of two sheets ,if found matching copying value of 4th column of first sheet to second
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM