counting empty cells VS spacebar and backspace

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I have column like the one below and at the bottom I have a function that count how many empty cells

= countif(A1:A10, "")

so Initially I have 3 cells empty. when I tried to empty a cell content in that range using Spacebar, the countif() would not count that cell but if I delete the content using Backspace then countif() will count that new empty cell.

I changed the function to the following =countif(A1:A10," ") , created space between the " "
what happened next is amazed me, now if I use the Backspace to delete cell content then countif() would not count that cell but if I use Spacebar to delete the cell content then countif() wil count that empty cell. So it is basically reverse of the first scenario.

Any idea why. Thank you so much.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
A space is a character, it's just one you can't see.

COUNTIF(A1:A10,"") won't count it because it has a character of length unit 1, i.e. " "

COUNTIF(A1:A10, " ") does count cells that appear to be empty if they have a space character in it, because that space character is of length 1 and matches the count if condition e.g. it is not COUNTIF(A1:A10,"a"), the string "a" vs string " " of space.

Put a mix of empty cells, cells with spaces and cells with text into A1:A10
In B1 enter formula "=LEN(A1)", drag this formula to B10
Evaluate the results
 
Upvote 0
If users of your sheet "might" use the space bar to delete the cell contents, you can use TRIM() in an adjacent cell to remove leading spaces.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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