Computing.Net > Forums > Office Software > Excel count function

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel count function

Reply to Message Icon

Name: itsfriday
Date: September 26, 2008 at 14:00:19 Pacific
OS: windows2000
CPU/Ram: excel
Comment:

I'm working with Office 2003. Sometimes I have to download survey results from an online form. Whenever I do that, the COUNT functions mess up if there are blanks. For example, the COUNTA function will count the blank cells until I manually click at each one of them. The the result of the COUNTA function will change. I can't do a replace either because there is nothing to replace. I wonder if anyone else has encountered this problem before?



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: September 27, 2008 at 11:01:31 Pacific
Reply:

It sounds as if Excel doesn't think the cells are really blank although I don't know why clicking on them would change that. There are many hidden characters that could be in the cells, but again, I don't know why clicking on them would make the hidden characters go away.

Have you tried to use =LEN() on the cells before you click on them to see if they return something other than zero? If they do then there are hidden characters in the cells that you might be able to replace with nothing.

Any chance of sending me a copy of the spreadsheet, or even just a range of cells that exhibits this problem?

If you'll either turn on Private Message or send me a PM, I'll respond with an email address that you can send the spreadsheet to.


0

Response Number 2
Name: itsfriday
Date: September 28, 2008 at 19:47:23 Pacific
Reply:

DerbyDad03, thanks for your reply. I tried Len() but it only returned zero. I couldn't replace anything because when I clicked into the cell it turned it into a blank cell and when I copied the whole cell there was nothing to paste. I know there's something in it because multiplying two of those cells gives me an error. I would love to send you the spreadsheet to have a look at it. It seems that I cannot send you a private message here since I started the thread. So here is my email address: hupuo@yahoo.com. Thank you so much!


0

Response Number 3
Name: jon_k
Date: September 29, 2008 at 01:28:25 Pacific
Reply:

Dunno if it's worth a try, but what do you get when you do

=COUNTA(A1:A10)-SUMPRODUCT(--(A1:A10=""))


0

Response Number 4
Name: DerbyDad03
Date: September 29, 2008 at 06:16:33 Pacific
Reply:

@ jon k: OK, I'm intrigued...what are you looking for with the formula you suggested?

With A1:A10 empty I get -10, with 1 entry I get -8, 2 yields -6, 10 yields 10.

Please explain your thought process.

Thanks!

@ itsfriday: I sent you an email address via Private Message.


0

Response Number 5
Name: itsfriday
Date: September 29, 2008 at 08:31:05 Pacific
Reply:

jon k: I got -4. The excel sheet was downloaded from an online survey form. Most fields are optional so respondents can leave then empty. Thus not all cells are affected.

DerbyDad03: I've sent you the spreadsheet. Thanks!


0

Related Posts

See More



Response Number 6
Name: DerbyDad03
Date: September 29, 2008 at 21:04:02 Pacific
Reply:

Thanks for sending me the spreadsheet.

The issue with your cells is that they are not empty.

One of the Remarks in the Excel Help files for COUNTA states:

- A value is any type of information, including error values and empty text (""). A value does not include empty cells.

If you set a Watch on c and d in the VBA editor and step through this code, you see that I132 (one of your problem cells) contains "" which is empty text, but A147 ( a "true blank" as you called it) contains . (You'll notice I didn't type anything there, because that's what VBA returns.)


Sub WhatsThere()
Set c = Range("I132")
Set d = Range("A147")
End Sub

Another test is to put a zero in a blank cell, copy it and do a "Paste Special...Add" to cells I4:I143. It won't put a zero in any cells that contain empty text since you can't add a number to text.

So, how do you solve your problem?

You could run this code against the sheet:


Sub MakeTrueBlanks()
Dim MyCell As Range
Application.ScreenUpdating = False
For Each MyCell In ActiveSheet.UsedRange
If MyCell.Value = "" Then MyCell.Clear
Next MyCell
Application.ScreenUpdating = True
End Sub

Good luck!

0

Response Number 7
Name: jon_k
Date: September 30, 2008 at 02:20:02 Pacific
Reply:

DD, I was checking to see if sumproduct differentiates between empty text and zero-length strings.

if you type ="" into a cell, the sumproduct formula will evaluate exactly the same way as if it is physically empty. So as a result, you can use

=SUMPRODUCT(--(A1:A10<>"")) which will sort out the problem without a macro, in theory. You'll need to change the range to suit your data.


0

Response Number 8
Name: DerbyDad03
Date: September 30, 2008 at 06:32:13 Pacific
Reply:

Thanks Jon.

I'll try that on the spreadsheet now that I have a copy of it. Can't to that until I get home tonight...

Interesting method.


0

Response Number 9
Name: itsfriday
Date: September 30, 2008 at 07:33:19 Pacific
Reply:

DerbyDad03:
It worked! Thank you thank you thank you!


0

Response Number 10
Name: DerbyDad03
Date: September 30, 2008 at 09:53:23 Pacific
Reply:

You're welcome.

Did you try jon k's suggestion, adjusted for the correct ranges? I'd be interested to hear if it works for you.

That might eliminate the need to run the macro every time you download the data.

=COUNTA(A1:A10)-SUMPRODUCT(--(A1:A10=""))


0

Response Number 11
Name: itsfriday
Date: September 30, 2008 at 19:08:52 Pacific
Reply:

The function itself didn't get the right result, but =2*COUNTA(A1:A10)-SUMPRODUCT(--(A1:A10="")) gave me the right count. However, if I click any one of the problematic cells (and turn it into a "true blank"), the result will change. So the macro still gives me more assurance. Thank you both DerbyDad03 and jon k!


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Excel count function

Count Function www.computing.net/answers/office/count-function/9660.html

URGENT ! Excel Counting Function www.computing.net/answers/office/urgent-excel-counting-function/1846.html

excel timer function www.computing.net/answers/office/excel-timer-function/91.html