我在 Excel 中有一個三串列,名為Table1,如下所示:

給定兩個值(每個輸入變數一個),一個必須與第一列(2、4、6 或 8)中的任何數字完全相等并且必須在單元格 F2 中鍵入,另一個可以是第二列中最小 (1) 和最大 (25) 數字之間的任何數字,并且必須在單元格 F3 中輸入,我想在第三列中找到相應的值。如果為第二個變數鍵入的值不存在于表的第二列中,則選擇下一行的輸出值。
例如,假設查找值是4(對于第一列)和10(對于第二列),那么輸出應該是E,因為4和10分別出現在第一列和第二列中,并且具有輸出的行E對應于輸入的那些值。
另一個例子。假設查找值是8(對于第一列)和17(對于第二列),那么輸出應該是K; 這不是J因為后者對應于第二列的值 15,該值嚴格小于17;所以輸出是K因為它對應于在后立即(或大于)的值17,是20。
我的嘗試
為了限制用戶可以選擇的可用值,我可以創建資料驗證單元格。為了選擇第一列中的值,資料驗證將按型別list并等于2, 4, 6, 8; 這樣的單元格將是 F2。像這樣:

對于在第二列選擇值時,資料驗證將是所述型別的whole number,具有minimum的值1和maximum的值25。像這樣:

Now the formulas for the lookup. After googling, I found out that performing a look-up task with two input criteria is known as a two-way lookup. Using the INDEX and MATCH functions, I managed to perform the two-way lookup, unfortunately the formula only allows exact matches, so it works fine when the first and second input values are 4 and 10, but not when they're 8 and 17. The formula is the following, and it is in cell F4:
{=INDEX(Table1[Output], MATCH($F$2 & "|" & $F$3, Table1[1st input variable] & "|" & Table1[2nd input variable], 0))}
(The presence of curly braces means that we must enter the formula with Ctrl Shift Enter instead of just Enter.)
Here's a screenshot for the first successful example:

Here's a screenshot for the second failed example:

我嘗試將 MATCH 函式的第三個引數從 0 更改為 1,但它回傳J(對應于第二列中的 15,但 17 < 15)而不是K(對應于 20,因為 17 > 20 和 20 是最接近的值到 17,緊跟在它之后。)
我怎樣才能達到我想要的?
uj5u.com熱心網友回復:
如果你有 Excel 365,那么你可以使用新的Filter函式:
=INDEX(FILTER(Table1[output],(Table1[1st Input variable]=first)*(Table1[2nd input variable]>=second),"no result"),1)
我將 F3 命名為“第一”,將 F4 命名為“第二”。
FILTER 回傳所有輸出值,其中
- A 列 = F3 中的值
- B列>=來自F4的值。
INDEX 選擇過濾結果的第一行
uj5u.com熱心網友回復:
不是最好的方法,但您可以將第二個輸入四舍五入到您需要的。在您的示例中,您的所有值都是 5 的倍數。只需使用 IF 為數字 1 創建一個例外。
這是我嘗試過的:

={INDEX($C$1:$C$12;MATCH(F7&IF(ROUNDUP(G7/5;0)=1;1;ROUNDUP(G7/5;0)*5);$A$1:$A$12&$B$1:$B$12;0))}
注意它是一個陣列公式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/326219.html
下一篇:將整數格式化為分數
