Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
167 views
in Technique[技术] by (71.8m points)

excel - VLOOKUP formula returns '#VALUE!' instead of the text value it should return

I wrote this formula in an Excel cell:

=IF(VLOOKUP(A2, VS!$B2:$B98,1,FALSE ),A2,NA)

What I want to do is, if it finds the A2 value in VS table from B2 to B92 then the function will return and input the value in A2 (in VS table) to my current table. But instead of getting the A2 values, which are text values, I got #VALUE!.

How can I solve it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try the following:

=IFERROR(VLOOKUP(A2,VS!$B2:$B98,1,FALSE),"")

What this does is return the value if it finds A2, in the range B2:B98, it doesn't find A2, it returns "" (blank), instead of #VALUE.

Secondly if you're planning on extending this formula, you may want to make the table more 'strictly typed' by adding '$' before the numbers so the range doesn't shift:

=IFERROR(VLOOKUP(A2,VS!$B$2:$B$98,1,FALSE),"")

Lastly, try right click -> Format Cells... and format column A as 'Text' and column B (on sheet VS) as Text as well. Sometimes Excel's Autoformatting features mess with vlookup's results.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...