简体   繁体   English

Excel公式基于两个单元格的值来计算一个单元格的值

[英]Excel formula to the value of a cell based on two cells' values

I might be asking for too much here but this is also a part of the requirement that I am working on from the below excel table I would like find the value of a specified cell if I give two different values and I would like to achieve that with the OFFSET , MATCH , INDEX functions in excel. 我可能在这里要求太多,但这也是我要从下面的excel表中进行处理的要求的一部分,如果我给出两个不同的值,我想找到指定单元格的值,并且我希望实现这一点在Excel中使用OFFSETMATCHINDEX函数。

There are two scenarios 有两种情况

Scenario 1: 方案1:

If I give value1=3500 (which is not in the first column) and value2=75 the Result1=1.59 and Result2=1.89 如果我给出value1 = 3500(不在第一列中)并且value2 = 75,则Result1 = 1.59和Result2 = 1.89

Scenario 2: 方案2:

If I give value1=3500 and value2=85 (both the values are not in the first row and first column of the grid) the resulting value should be Result1=1.59, Result2=1.89, Result3=1.51, Result4= 1.81` 如果我给出value1 = 3500和value2 = 85(这两个值均不在网格的第一行和第一列中),则结果值应为Result1 = 1.59,Result2 = 1.89,Result3 = 1.51,Result4 = 1.81`

How can I achieve this within excel? 如何在excel中实现这一目标?

Measure |2.5    |5      |10     |25     |50     |75     |100    |150    |200    
250     |0.835  |0.75   |0.69   |0.6    |0.528  |0.455  |0.383  |0.314  |0.245  
500     |1.044  |0.938  |0.863  |0.75   |0.675  |0.6    |0.525  |0.451  |0.378  
1000    |1.391  |1.25   |1.15   |1      |0.923  |0.845  |0.768  |0.689  |0.61   
2000    |1.948  |1.75   |1.52   |1.4    |1.321  |1.243  |1.164  |1.083  |1.002  
3000    |2.435  |2.188  |1.95   |1.75   |1.67   |1.59   |1.51   |1.426  |1.343  
4000    |2.853  |2.563  |2.3    |2.05   |1.97   |1.89   |1.81   |1.726  |1.643  
5000    |3.507  |3.15   |2.675  |2.4    |2.269  |2.188  |2.107  |2.021  |1.936  
10000   |       |4.553  |4      |3.72   |3.56   |3.477  |3.394  |3.304  |3.215  
15000   |       |5.691  |5      |4.6    |4.469  |4.385  |4.301  |4.209  |4.117  
20000   |       |6.545  |5.8    |5.3    |5.151  |5.066  |4.981  |4.888  |4.795  
25000   |       |7.527  |6.4    |5.83   |5.666  |5.573  |5.48   |5.377  |5.274  
50000   |       |9.785  |8.32   |7.579  |7.366  |7.245  |7.123  |6.99   |6.856  

I've only just noticed this problem when browsing through stackoverflow today, and since it was never actually addressed in its entirety, I've decided to answer it for future reference by individuals facing the same problem. 我只是在今天浏览stackoverflow时才注意到此问题,由于实际上从未完整地解决过此问题,因此我决定回答此问题,以供将来面临相同问题的个人参考。

This is one of the many possible approaches to this question: 这是解决此问题的多种可能方法之一

Assume the Measure table is placed in the range A1:J13 of an Excel worksheet, Value 1 is in the cell A16, Value 2 is in the cell C16 and Result values 1 to 4 are stored in the cell range E16:F17, then we can use the following formulae in Excel 2010/2013 to extract the information which you require: 假设Measure表放置在Excel工作表的范围A1:J13中,值1在单元格A16中,值2在单元格C16中,结果值1至4存储在单元格范围E16:F17中,那么我们可以在Excel 2010/2013中使用以下公式来提取所需的信息:

In cell E16 (the cell storing the value for Result 1), enter the following formula: 在单元格E16(存储结果1的值的单元格)中,输入以下公式:

=IF(AND(IFERROR(MATCH(A16,A1:A13,0),FALSE), IFERROR(MATCH(C16,A1:J1,0),FALSE)),INDEX((OFFSET($A$1:$J$13,(MATCH(A16,A1:A13,0)-1),(MATCH(C16,A1:J1,0)-1))),1,1), INDEX((OFFSET($A$1:$J$13,(MATCH(A16,A1:A13,1)-1),(MATCH(C16,A1:J1,1)-1))),1,1))

In cell E17 (the cell storing the value for Result 2), enter the following formula: 在单元格E17(存储结果2的值的单元格)中,输入以下公式:

=IF((IFERROR(MATCH(A16,A1:A13,0),FALSE))," ", INDEX((OFFSET($A$1:$J$13,(MATCH(A16,A1:A13,1)),(MATCH(C16,A1:J1,1)-1))),1,1))

In cell F16 (the cell storing the value for Result 3), enter the following formula: 在单元格F16(存储结果3的值的单元格)中,输入以下公式:

=IF((IFERROR(MATCH(C16,A1:J1,0),FALSE)),"",INDEX((OFFSET($A$1:$J$13,(MATCH(A16,A1:A13,1)-1),(MATCH(C16,A1:J1,1)))),1,1))

In cell F17 (the cell storing the value for Result 4), enter the following formula: 在单元格F17(存储结果4的值的单元格)中,输入以下公式:

=IF(AND(IFERROR(MATCH(A16,A1:A13,0),FALSE)=FALSE, IFERROR(MATCH(C16,A1:J1,0),FALSE)=FALSE),INDEX((OFFSET($A$1:$J$13,(MATCH(A16,A1:A13,1)),(MATCH(C16,A1:J1,1)))),1,1)," ")

In case this helps, the following formulae seem to display the values at the corners, assuming Measure is a named range starting in A1 and value1 and value2 are named ranges: 为了防止这种情况,假设Measure是从A1开始的命名范围,而value1和value2则是命名范围,以下公式似乎在拐角处显示值:

=INDEX(Measure,IFERROR(MATCH(value1,A:A,0),MATCH(value1,A:A,1)),IFERROR(MATCH(value2,1:1,0),MATCH(value2,1:1,1))) = INDEX(测量,IFERROR(MATCH(值1,A:A,0),MATCH(值1,A:A,1)),IFERROR(MATCH(value2,1:1,0),MATCH(value2,1:1 ,1)))

=INDEX(Measure,IFERROR(MATCH(value1,A:A,0),MATCH(value1,A:A,1)),IFERROR(MATCH(value2,1:1,0),MATCH(value2,1:1,1)+1)) = INDEX(测量,IFERROR(MATCH(值1,A:A,0),MATCH(值1,A:A,1)),IFERROR(MATCH(value2,1:1,0),MATCH(value2,1:1 ,1)+1))

=INDEX(Measure,IFERROR(MATCH(value1,A:A,0),MATCH(value1,A:A,1)+1),IFERROR(MATCH(value2,1:1,0),MATCH(value2,1:1,1))) = INDEX(测量,IFERROR(MATCH(值1,A:A,0),MATCH(值1,A:A,1)+1),IFERROR(MATCH(value2,1:1,0),MATCH(value2,1 :1,1)))

=INDEX(Measure,IFERROR(MATCH(value1,A:A,0),MATCH(value1,A:A,1)+1),IFERROR(MATCH(value2,1:1,0),MATCH(value2,1:1,1)+1)) = INDEX(测量,IFERROR(MATCH(值1,A:A,0),MATCH(值1,A:A,1)+1),IFERROR(MATCH(value2,1:1,0),MATCH(value2,1 :1,1)+1))

Not exactly what you want but here is my try: 不完全是您想要的,但是我尝试了:

Enter following formula for B19 , then copy&paste to all cell in green table. B19输入以下公式,然后将其复制并粘贴到绿色表格中的所有单元格中。

=IF(OR(AND($B$15=$A19,$B$16=B$18),AND($B$15>$A18,$B$15<$A20,$B$16>A$18,$B$16<C$18)),B2,0)

在此处输入图片说明

Assuming your workbook is placed into the named range Measure(B2:J13), Value 1(B15) and Value 2(B16), then the formulas: 假设您的工作簿被放置在名为Measure(B2:J13),值1(B15)和值2(B16)的范围内,则公式如下:

=INDEX(Measure,MATCH(Value_1,$A$2:$A$13,1),MATCH(Value_2,$B$1:$J$1,1))
=INDEX(Measure,MATCH(Value_1,$A$2:$A$13,1),MATCH(Value_2,$B$1:$J$1,1)+1)
=INDEX(Measure,MATCH(Value_1,$A$2:$A$13,1)+1,MATCH(Value_2,$B$1:$J$1,1))
=INDEX(Measure,MATCH(Value_1,$A$2:$A$13,1)+1,MATCH(Value_2,$B$1:$J$1,1)+1)

will return the values you require. 将返回您需要的值。 Use the MATCH function to select the row, selectively offset it with the + 1 (or similar) and then use INDEX to select the item in the table. 使用MATCH函数选择行,用+ 1 (或类似值)有选择地偏移它,然后使用INDEX选择表中的项目。

The table layout is cosmetic. 桌子的布局是美观的。 Nothing prevents the column and row labels from being elsewhere entirely. 没有什么可以阻止列和行标签完全位于其他位置。 The Named ranges reference the input values. 命名范围引用输入值。

Additional input values of 1000, 10 return the results 1.15, 1, 1.52, 1.4. 附加输入值1000、10返回结果1.15、1、1.52、1.4。

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

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