简体   繁体   中英

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.

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:

=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.

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.

UPDATE

If you have numeric time values in the TIME columns then this formula is what you need. Enter it in cell 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 .

After confirming this array formula in cell C3, copy it.

Now, select C4 through C50 (or however deep you need) and paste.

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.

By staggering the lookup ranges between the INDEX and MATCH function pair you can overcome the problems with your merged cells.

最佳百分比

The standard formula in B2 is,

=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(...) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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