Share via

IF function not returning results every time

Anonymous
2024-12-06T22:11:57+00:00

I need "Yes" to be returned if the data in C2 matches A1:A12 on Sheet 2 and if not return "No".

I entered this function:

=IFERROR(IF((VLOOKUP(C2,'Sheet2'!A1:A12,1,TRUE))=C2,"yes","no"),"")

This only works part time, the data on sheet2 in columns A1:A12 all start with the number 7. In testing I have found if I enter a number in my reference cell, C2, that starts with a 7 or higher I either get "Yes"/"No" depending on if it matches one of the cells in sheet2 A1:A12 (working as expected). But, if I enter a number that starts with a number lower than 7 the function errors with no result. Not sure what is causing this.

For example:

If Sheet2 A1:A12 contained

7500
7503
7504
7705
7507
7509
7568
7745
7747
7748

If I enter 7503 in cell C2, it would return "Yes"

If I enter 7777 in cell C2 it would return "No"

If I enter 9999 in cell C2 it would return "No"

If I enter 5306 in cell C2 nothing is returned

If I enter 1111 in cell C2 nothing is returned

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2024-12-06T22:24:25+00:00

    For VLOOKUP with TRUE as 4th argument, the lookup range 'Sheet2'!A1:A12 should be sorted in ascending order.

    But 7705 in A4 is lager than 7507 in A5.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more