简体   繁体   English

根据另一个单元格值返回一个单元格值

[英]Return a cell value based on another cell value

I am working on a project at work and I need to come up with a solution that will allow me to use formulas only.我正在做一个工作项目,我需要想出一个解决方案,让我只能使用公式。 Ignoring what the values mean, I need a formula that look for the highest value in a row and then place the supplier in the corresponding cell.忽略这些值的含义,我需要一个公式来查找一行中的最高值,然后将供应商放在相应的单元格中。

So in this example, I need the formula to see that H3 is the highest value in the first row, and as a result put Supplier 3 in cell B3.所以在这个例子中,我需要公式来查看 H3 是第一行中的最高值,因此将供应商 3 放在单元格 B3 中。

The formula needs to be smart enough to know allow for the fact the highest value will likely be in a different column on the next row and will need to show a different result in it corresponding cell.该公式需要足够聪明,以知道最高值可能位于下一行的不同列中,并且需要在相应的单元格中显示不同的结果。

My spreadsheet example我的电子表格示例

Please someone tell me that this is possible!请有人告诉我这是可能的!

This will work if there are no NUMBER values in the TIME columns:如果 TIME 列中没有 NUMBER 值,这将起作用:

=INDEX(C$1:Z$1,MATCH(MAX(C3:Z3),C3:Z3,)-1)

Note: This assumes that your supplier columns do not extend past column Z. If they do, then change the z's in the formula to something further out that will accommodate your scenario.注意:这假设您的供应商列不超过 Z 列。如果确实如此,请将公式中的 z 更改为更远的值,以适应您的情况。

Note: If you have time values (not text, but actual numbers that are formatted to look like time) in the TIME columns then you'll need a different approach.注意:如果您在 TIME 列中有时间值(不是文本,而是格式化为看起来像时间的实际数字),那么您将需要不同的方法。

UPDATE更新

If you have numeric time values in the TIME columns then this formula is what you need.如果您在 TIME 列中有数字时间值,那么这个公式就是您所需要的。 Enter it in cell C3:在单元格 C3 中输入:

=INDEX(C$1:Z$1,MATCH(MAX(N(OFFSET(C3,,ROW(OFFSET($A$1,,,12))*2-1))),C3:Z3,)-1)

This is an array formula and must be confirmed with Ctrl + Shift + Enter .这是一个数组公式,必须使用Ctrl + Shift + Enter 确认

After confirming this array formula in cell C3, copy it.在单元格 C3 中确认此数组公式后,复制它。

Now, select C4 through C50 (or however deep you need) and paste.现在,选择 C4 到 C50(或您需要的深度)并粘贴。

Note: If you need more supplier columns, change the z's and increase the 12 in the middle of the formula to the max number (or more) of suppliers.注意:如果您需要更多供应商列,请更改 z 并将公式中间的12增加到最大供应商数(或更多)。

By staggering the lookup ranges between the INDEX and MATCH function pair you can overcome the problems with your merged cells.通过在INDEXMATCH函数对之间交错查找范围,您可以克服合并单元格的问题。

最佳百分比

The standard formula in B2 is, B2中的标准公式是,

=INDEX($C$1:$Y$1, MATCH(MAX(INDEX($D3:$Z3*NOT(MOD(COLUMN($D:$Z), 2)), , )), $D3:$Z3, 0))

The MOD function returns a remainder of a division so the odd numbered columns will return 1 and the even numbered columns a 0. This is reversed with NOT(...) . MOD 函数返回除法的余数,因此奇数列将返回 1,偶数列将返回 0。这与NOT(...)相反。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM