Formula To Check Whether A Value Exists In A Range Is Reporting Incorrectly

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,562
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am looking for some help with this formula ...

Code:
=IF(COUNTIF(D182,[Rental_Detail.xlsm]Rental_Data!$A:$A) >0, "YES","NO")"

D182 = 84351

This value does exist in workbook Rental_Detail.xlsm, worksheet Rental_Data, column A ... but the formula is wrongly saying it doesn't.
 
Last edited:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi there. Check the cell type set for column A and D182. If they are different, then I suspect it's because numeric and text don't necessarily match even when to the eye they look the same.
 
Upvote 0
Reverse the COUNTIF:

=IF(COUNTIF([Rental_Detail.xlsm]Rental_Data!$A:$A,D182) >0, "YES","NO")
 
Upvote 0
Thank you John, so if I did what I should to ensure that, I set the format of both columns to "Number", 0 decimal points.
No, the formula results in yes for everything, even when the value isn't in the list.
 
Upvote 0
OOPS Rory is right - I didn't look at your formula properly. Do what he says.
 
Upvote 0
Thanks Rory, that was the solution.

Code:
=VLOOKUP(D410,[Rental_Detail.xlsm]Rental_Data!$A:$D,3,FALSE)

This is also giving me problems. All I get is #N/A even when the formula should work. I tried playing with it similar to your suggestion for my OP, but that gave me a #VALUE error.
 
Last edited:
Upvote 0
All I get is #N/A even when the formula should work
That simply means it is not finding a match for the value in D410.
Note that it much match EXACTLY.
Any extra spaces in one will cause it not to match.
Any you cannot compare a number to a "number entered as text".
 
Upvote 0
Any you cannot compare a number to a "number entered as text".

I suspect that is the issue. COUNTIF will treat them the same, but VLOOKUP (and MATCH) will not.
 
Upvote 0
That was the issue ... one of the two columns was likely text. I'm not sure which one, but I converted them to numbers, and all seems well.
Thank you all!!
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,214
Members
448,874
Latest member
b1step2far

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top