在一行中查找匹配的值并返回列名?

Tei*_*eiv 1 microsoft-excel

我有一个样品价格,我想在同一行中找到提供最低或与该样品价格相同的价格的公司,并将其名称放在“公司名称”列中。我尝试使用 IF 进行比较,但它会导致大表出现“参数过多”错误。谁能告诉我如何实现它?

Price   Company A   Company B   Company C    Company Name
5       5           6           7           Company A
3       9           3           8           Company B
Run Code Online (Sandbox Code Playgroud)

Pau*_*aul 6

好了,走吧。您的问题是“最低或等于”样品价格,但不要说如果价格高于样品价格该怎么办。所以我只选择最低的:

这会找到最低价格(我假设公司列是 BD):

=min(B2:d2)            (equals 5 for your first row)
Run Code Online (Sandbox Code Playgroud)

这将找到最低价格的列位置:

=match(min(b2:d2), b2:d2,0)      (equals 2 because that is the position of the lowest (5) in your first row)
Run Code Online (Sandbox Code Playgroud)

这将返回具有最小值的列的第一行中的值:

=index(b$1:d$1 ,match(min(b2:d2), b2:d2,0)))     (returns "Company A" - the contents of that cell) 
Run Code Online (Sandbox Code Playgroud)

所以最后一个公式就是你所需要的,前面的步骤只是为了解释我们是如何到达那里的。