Excel公式,如果一个单元格等于特定范围,请复制匹配单元格旁边的单元格 [英] Excel formula if a cell is equal to a specific range, copy the cell next to the matching cell

查看:71
本文介绍了Excel公式,如果一个单元格等于特定范围,请复制匹配单元格旁边的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果单元格等于特定范围的单元格,我可以获取Excel公式,将其复制到匹配单元格旁边,否则显示0.

Can I get an Excel formula for if a cell is equal to a cell of a specific range, copy the cell next to the matching cell, otherwise show 0.

即从D2中的屏幕截图中,检查C2是否在F2:F8范围内,如果是,则显示100(对应F2旁边的单元格),否则显示0.

I.e. from the screenshot in D2, check if C2 is in the range of F2:F8 and if so, show 100 (the cell next to the corresponding F2) otherwise, show 0.

推荐答案

这将检查vlookup是否返回错误并返回0,否则将正常执行vlookup.

This will check if the vlookup returns an error and return 0, otherwise, it will do the vlookup normally.

=IFERROR(VLOOKUP(C2,$F$2:$G$8,2,FALSE),0)

如果您只想捕获#N/A 错误(而不是例如 #REF 错误),则有另一种方法.请注意,这需要两个vlookup,因此运行速度较慢.

If you want to catch only #N/A errors (and not #REF errors, for example) there is another approach. Note that this requires two vlookups and therefore runs slower.

=IF(ISNA(VLOOKUP(C2,$F$2:$G$8,2,FALSE)),0,VLOOKUP(C2,$F$2:$G$8,2,FALSE))

这篇关于Excel公式,如果一个单元格等于特定范围,请复制匹配单元格旁边的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆