Why COUNTIF() returns zero in excel?

Noni

Board Regular
Joined
Aug 27, 2022
Messages
63
Office Version
  1. 2021
Platform
  1. Windows
I've two columns of addresses (2022 customer address, and 2023 customer address) on the same sheet. I want to check if a 2023 address in column D is of an existing or new customer (comparing it with column C). I also aim to find out if the 2022 customer is no longer a customer in 2023.

=COUNTIF($C$2:$C$256,D2)
with the above formula, I'm checking if D2 exists in C2:C256 but I'm getting zero results though I know that D2(address) does exist in the range C2:C256. please help!!!!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I am probably barking up the wrong tree but in the data you copied in, in post #3 the only 2 that match seem to have something before the address which appears in your representation as an additional cell / box.
When I copy it into excel it is pushing those 2 into another column.

Is there something unusual about those cells ? Merge cells spring to mind but I can't reproduce it.
If you go =len(cell_ref) on the 5C, 256 New Drive FGH 6093 on the right hand side does it return 26 ?
1661671148056.png
 
Upvote 0
It is returning zero for me
@Noni
@Shift-dell is talking about a formula like this where you directly compare two cells that appear the same. As you see below, both pairs of coloured cells appear the same but one pair is not.

22 08 28.xlsm
CDE
12023 address2022 Address
2215/20B ABCD XYZ 60975C, 256 New Drive FGH 6093TRUE
3167 XYZ Road ABC 6098345 ABC Road OIU 1234
45C, 256 New Drive FGH 60931267 kjh/asd Cres OLM 1234
51209 jhgf Rd OLM 1234
6167 XYZ Road ABC 6098FALSE
COUNTIF
Cell Formulas
RangeFormula
E2E2=C4=D2
E6E6=C3=D6


It should help greatly if you could give us your sample data with XL2BB as then we could be more sure that we are testing with exactly the same data as you.

(I'm wondering if the data, or one column at least contains CHAR(160) or similar rather than a standard space character?)
 
Upvote 0
@Noni
@Shift-dell is talking about a formula like this where you directly compare two cells that appear the same. As you see below, both pairs of coloured cells appear the same but one pair is not.

22 08 28.xlsm
CDE
12023 address2022 Address
2215/20B ABCD XYZ 60975C, 256 New Drive FGH 6093TRUE
3167 XYZ Road ABC 6098345 ABC Road OIU 1234
45C, 256 New Drive FGH 60931267 kjh/asd Cres OLM 1234
51209 jhgf Rd OLM 1234
6167 XYZ Road ABC 6098FALSE
COUNTIF
Cell Formulas
RangeFormula
E2E2=C4=D2
E6E6=C3=D6


It should help greatly if you could give us your sample data with XL2BB as then we could be more sure that we are testing with exactly the same data as you.

(I'm wondering if the data, or one column at least contains CHAR(160) or similar rather than a standard space character?)
See some Progress.. I used TRIM function to remove spaces . Thanks all.
One more question. How can I clean this address? 12 ABC str eet XYZ 27 09

It should be 12 ABC street XYZ 2709
 
Upvote 0
How can I clean this address? 12 ABC str eet XYZ 27 09

It should be 12 ABC street XYZ 2709
The original text has 6 spaces and the desired result has 4 spaces. What is the logic for which spaces should be removed?
 
Upvote 0
The original text has 6 spaces and the desired result has 4 spaces. What is the logic for which spaces should be removed?
The last four numbers are post code of an address. It should be 2709 not 27 09
 
Upvote 0

Forum statistics

Threads
1,215,671
Messages
6,126,131
Members
449,293
Latest member
yallaire64

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