View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Nulls vs. blanks?

If you have a cell that appears to be empty, you can test it with the
following formula (the Rosenfeld Formula):

=IF(ISBLANK(A1),0,IF(AND(LEN(A1)=0,CELL("prefix",A 1)="'"),-2,IF(LEN(A1)=0,-1,CODE(A1))))

the formula will return 0 if A1 is genuinely empty
the formula will return -1 if A1 has a fomula returning null ("")
the formula will return -2 if A1 has a single apostrophe in it
the formula will return 32 is A1 has a space in it

The formula will return the ASCII value of the character otherwise.

Even though a cell LOOKS empty, the formula above will tell you whats really
in it.
--
Gary''s Student - gsnu200770


"DesertCyclist" wrote:

I have a spreadsheet with a field that may contain blanks (empty). When I
filter on that field to show only the blanks, I get 4000 records returned.
But if I import the spreadsheet into SQL Server, the test in there for blanks
('') returns nothing. However, if I test for Nulls in that field, I get 5000
records returned. I don't know which one (Excel or SQL Server) is giving me
the right answer. Can anyone help me understand what's going on?

Thanks!