VLOOKUP在excel中

时间:2014-06-26 01:58:15

标签: excel excel-vba excel-formula vba

假设我有3列

A       B       C
1      8        0
2      9        0.3
3      15       0.1
4      16       0.01
5      17       0.02
6      18       0.05

我需要在c列中找到大于0.1且小于-0.1的值。我可以使用条件格式选项卡。找到这些值后,我需要在A列中找到相应的值,然后使用我需要的那些值来查找B列中的值,其中A列和B列中的值之间的差值小于8。例如,让我们在C列中取0.3,A列中的相应值是2.查看BI列中的所有值,请参阅8-2< 8,因此我需要在D列中打印。我还需要打印9-2,因为这是但是我不应该打印15-3,因为这个值大于8.我知道我需要使用VLOOKUP但是我对如何继续进行了迷失。有人可以帮帮我吗?

A       B       C        D
1      8        0
2      9        0.3      6,7
3      15       0.1
4      16       0.01
5      17       0.02
6      18       0.05

第6行的输出样本为6,7。得到6,7的方法如下。由于在列C 0.3> 0.1其中0.1由我们定义(条件格式),我们从列B中获取所有值。从列A中减去列B中的每个值(我们取减法后的绝对值)。例如,对于0.3,A列中的对应值是2.我们从B列中的每个值中减去它.2-8,2-9,2-15,2-16,2-17,2-18和等等。从这些值中我们只选择小于8的值(由我们再次定义)。所以只有2个值是6,7,因为其他所有值的绝对值都大于8.我们在D列中打印这个值。

1 个答案:

答案 0 :(得分:0)

这是一个令人困惑的问题,但我想我明白你要求的是什么。将其放入单元格D1并填写:

=IF(AND(OR(C1>0.1,C1<-0.1),LEN(IF(NOT(ISERROR(MATCH(A1,$B$1:$B$6,0))),"0,","")&IF(NOT(ISERROR(MATCH(A1+1,$B$1:$B$6,0))),"1,","")&IF(NOT(ISERROR(MATCH(A1+2,$B$1:$B$6,0))),"2,","")&IF(NOT(ISERROR(MATCH(A1+3,$B$1:$B$6,0))),"3,","")&IF(NOT(ISERROR(MATCH(A1+4,$B$1:$B$6,0))),"4,","")&IF(NOT(ISERROR(MATCH(A1+5,$B$1:$B$6,0))),"5,","")&IF(NOT(ISERROR(MATCH(A1+6,$B$1:$B$6,0))),"6,","")&IF(NOT(ISERROR(MATCH(A1+7,$B$1:$B$6,0))),"7,",""))>1),LEFT(IF(NOT(ISERROR(MATCH(A1,$B$1:$B$6,0))),"0,","")&IF(NOT(ISERROR(MATCH(A1+1,$B$1:$B$6,0))),"1,","")&IF(NOT(ISERROR(MATCH(A1+2,$B$1:$B$6,0))),"2,","")&IF(NOT(ISERROR(MATCH(A1+3,$B$1:$B$6,0))),"3,","")&IF(NOT(ISERROR(MATCH(A1+4,$B$1:$B$6,0))),"4,","")&IF(NOT(ISERROR(MATCH(A1+5,$B$1:$B$6,0))),"5,","")&IF(NOT(ISERROR(MATCH(A1+6,$B$1:$B$6,0))),"6,","")&IF(NOT(ISERROR(MATCH(A1+7,$B$1:$B$6,0))),"7,",""),LEN(IF(NOT(ISERROR(MATCH(A1,$B$1:$B$6,0))),"0,","")&IF(NOT(ISERROR(MATCH(A1+1,$B$1:$B$6,0))),"1,","")&IF(NOT(ISERROR(MATCH(A1+2,$B$1:$B$6,0))),"2,","")&IF(NOT(ISERROR(MATCH(A1+3,$B$1:$B$6,0))),"3,","")&IF(NOT(ISERROR(MATCH(A1+4,$B$1:$B$6,0))),"4,","")&IF(NOT(ISERROR(MATCH(A1+5,$B$1:$B$6,0))),"5,","")&IF(NOT(ISERROR(MATCH(A1+6,$B$1:$B$6,0))),"6,","")&IF(NOT(ISERROR(MATCH(A1+7,$B$1:$B$6,0))),"7,",""))-1),"")

这是一个很长的公式,但它实际上是相同的核心公式三次写入(一次确定字符串的长度,一次返回它,再次删除尾随&#34;,& #34;。)

我认为值是正数,你的意思是&gt; 0.1而不是&gt; = 0.1(根据我对你的问题的评论,你在后一点上不一致)。

如果您愿意,可以更改范围以包含更多行或整列。

一个较短的版本,会给你留下一个&#34;,&#34;在你的最终价值的最后是这个(只是为了你理解它是如何工作的):

=IF(OR(C1>0.1,C1<-0.1),IF(NOT(ISERROR(MATCH(A1,$B$1:$B$6,0))),"0,","")&IF(NOT(ISERROR(MATCH(A1+1,$B$1:$B$6,0))),"1,","")&IF(NOT(ISERROR(MATCH(A1+2,$B$1:$B$6,0))),"2,","")&IF(NOT(ISERROR(MATCH(A1+3,$B$1:$B$6,0))),"3,","")&IF(NOT(ISERROR(MATCH(A1+4,$B$1:$B$6,0))),"4,","")&IF(NOT(ISERROR(MATCH(A1+5,$B$1:$B$6,0))),"5,","")&IF(NOT(ISERROR(MATCH(A1+6,$B$1:$B$6,0))),"6,","")&IF(NOT(ISERROR(MATCH(A1+7,$B$1:$B$6,0))),"7,",""),"")