A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Counting Items



 
 
Thread Tools Display Modes
  #11  
Old June 22nd, 2008, 06:23 PM posted to microsoft.public.excel.worksheet.functions
Jakobshavn Isbrae
external usenet poster
 
Posts: 47
Default Counting Items

Thank you very much
--
jake


"Rick Rothstein (MVP - VB)" wrote:

Or, I guess more simply (that is, one less function call), this...

=SUMPRODUCT(--(A1:A1000""))

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
You could try this...

=SUMPRODUCT(--(LEN(A1:A1000)0))

where you would chose a top-end to the range greater than the largest row
you ever expect to use.

Rick


"Jakobshavn Isbrae" wrote in
message ...
How can I count the number of items in a column whose length exceeds
zero?
--
jake




  #12  
Old June 22nd, 2008, 06:26 PM posted to microsoft.public.excel.worksheet.functions
Jakobshavn Isbrae
external usenet poster
 
Posts: 47
Default Counting Items

Thank you very much for taking the time to offer help. The formula seems to
ignore numbers.
--
jake


"T. Valko" wrote:

Try this:

=COUNTIF(A1:A10,"?*")

--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote in
message ...
I put this formula in A1...

=IF(MOD(ROW(A1),3),"X","")

and copied it down to A10. On my copy of XL2003, your formula, as well as
the other formulas that were posted (except for mine, of courseg),
returns 10 instead of 7 meaning it counted the blank (looking) cells as
well as the non-blank looking ones.

Rick


"Pete_UK" wrote in message
...
Try using COUNTIF, i.e.:

=COUNTIF(A:A,"")

will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")

Hope this helps.

Pete

On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds
zero?
--
jake





  #13  
Old June 22nd, 2008, 06:30 PM posted to microsoft.public.excel.worksheet.functions
Jakobshavn Isbrae
external usenet poster
 
Posts: 47
Default Counting Items

First, thank you for taking the time to respond. Your formula does count
text and numbers, but also counts nulls.
--
jake


"Pete_UK" wrote:

Try using COUNTIF, i.e.:

=COUNTIF(A:A,"")

will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")

Hope this helps.

Pete

On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds zero?
--
jake



  #14  
Old June 22nd, 2008, 06:35 PM posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\)[_730_]
external usenet poster
 
Posts: 1
Default Counting Items

Biff's formula worked for me with either text or numbers. What formula are
you using in your cells (I'd like to see why you are saying it doesn't work
for you)?

Rick


"Jakobshavn Isbrae" wrote in
message ...
Thank you very much for taking the time to offer help. The formula seems
to
ignore numbers.
--
jake


"T. Valko" wrote:

Try this:

=COUNTIF(A1:A10,"?*")

--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote
in
message ...
I put this formula in A1...

=IF(MOD(ROW(A1),3),"X","")

and copied it down to A10. On my copy of XL2003, your formula, as well
as
the other formulas that were posted (except for mine, of courseg),
returns 10 instead of 7 meaning it counted the blank (looking) cells as
well as the non-blank looking ones.

Rick


"Pete_UK" wrote in message
...
Try using COUNTIF, i.e.:

=COUNTIF(A:A,"")

will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")

Hope this helps.

Pete

On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds
zero?
--
jake





  #15  
Old June 22nd, 2008, 06:37 PM posted to microsoft.public.excel.worksheet.functions
T. Valko
external usenet poster
 
Posts: 15,759
Default Counting Items

I'm guessing the answer will probably be "yes"

You are correct.

One of the biggest reasons and one that folks don't seem to consider is that
since SP works on arrays it evaluates *every* reference in the array
arguments.

=COUNTIF(A:A,"X")

Is very efficient because COUNTIF will only evaluate the used range.

=SUMPRODUCT(--(A1:A1000="x"))

Will evaluate every cell in A1:A1000 even if the used range only goes to
A100.

In Excel 2007:

=SUMPRODUCT(--(A:A="x"))

Is "crazy"!

I was more interested in its "scale of slowness" as opposed to the simple
fact that it is slower.


There is code here to test calculation times:

http://msdn2.microsoft.com/en-us/library/aa730921.aspx


--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote in
message ...
Yes, of course, wildcards... that works fine.

I find my inclination is to go to the SUMPRODUCT function because of it
vast flexibility as a calculation engine. I was wondering if you knew (or
if anyone else reading this message knows) whether the SUMPRODUCT is, by
its very nature as a universal type calculation engine, a necessarily slow
function compared to the more targeted functions (such as your COUNTIF
formula compared to my SUMPRODUCT formula)? I'm guessing the answer will
probably be "yes", but I was more interested in its "scale of slowness" as
opposed to the simple fact that it is slower.

Rick


"T. Valko" wrote in message
...
Try this:

=COUNTIF(A1:A10,"?*")

--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote
in message ...
I put this formula in A1...

=IF(MOD(ROW(A1),3),"X","")

and copied it down to A10. On my copy of XL2003, your formula, as well
as the other formulas that were posted (except for mine, of courseg),
returns 10 instead of 7 meaning it counted the blank (looking) cells as
well as the non-blank looking ones.

Rick


"Pete_UK" wrote in message
...
Try using COUNTIF, i.e.:

=COUNTIF(A:A,"")

will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")

Hope this helps.

Pete

On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds
zero?
--
jake






  #16  
Old June 22nd, 2008, 06:47 PM posted to microsoft.public.excel.worksheet.functions
T. Valko
external usenet poster
 
Posts: 15,759
Default Counting Items

Yes, that formula works on TEXT only.

In general, wildcards work on text only.

If you will have mixed data types then I would use Rick's suggestion:

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

--
Biff
Microsoft Excel MVP


"Jakobshavn Isbrae" wrote in
message ...
Thank you very much for taking the time to offer help. The formula seems
to
ignore numbers.
--
jake


"T. Valko" wrote:

Try this:

=COUNTIF(A1:A10,"?*")

--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote
in
message ...
I put this formula in A1...

=IF(MOD(ROW(A1),3),"X","")

and copied it down to A10. On my copy of XL2003, your formula, as well
as
the other formulas that were posted (except for mine, of courseg),
returns 10 instead of 7 meaning it counted the blank (looking) cells as
well as the non-blank looking ones.

Rick


"Pete_UK" wrote in message
...
Try using COUNTIF, i.e.:

=COUNTIF(A:A,"")

will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")

Hope this helps.

Pete

On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds
zero?
--
jake






  #17  
Old June 22nd, 2008, 06:52 PM posted to microsoft.public.excel.worksheet.functions
Pete_UK
external usenet poster
 
Posts: 8,780
Default Counting Items

Rick,

SUMIF and COUNTIF are much faster than SUMPRODUCT (or SUM(IF .. )
array formula) equivalents when you have a lot of rows. I analyse
telephone data for clients, where we might have 40,000 call records a
month (or more), and I have shown (to myself) that SP formulae are
much slower. It often pays to join several columns together and do a
SUMIF on the concatenated values rather than have SP with lots of
criteria in them (eg calls made of a particular type in a particular
charging period from a particular phone number between two particular
dates - you end up with 5 SP criteria each of 40,000 rows, whereas by
concatenating them together allows SUMIF to scan through just one
array).

Pete

On Jun 22, 6:14*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Yes, of course, wildcards... that works fine.

I find my inclination is to go to the SUMPRODUCT function because of it vast
flexibility as a calculation engine. I was wondering if you knew (or if
anyone else reading this message knows) whether the SUMPRODUCT is, by its
very nature as a universal type calculation engine, a necessarily slow
function compared to the more targeted functions (such as your COUNTIF
formula compared to my SUMPRODUCT formula)? I'm guessing the answer will
probably be "yes", but I was more interested in its "scale of slowness" as
opposed to the simple fact that it is slower.

Rick

"T. Valko" wrote in message

...



Try this:


=COUNTIF(A1:A10,"?*")


--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote in
. ..
I put this formula in A1...


=IF(MOD(ROW(A1),3),"X","")


and copied it down to A10. On my copy of XL2003, your formula, as well as
the other formulas that were posted (except for mine, of courseg),
returns 10 instead of 7 meaning it counted the blank (looking) cells as
well as the non-blank looking ones.


Rick


"Pete_UK" wrote in message
...
Try using COUNTIF, i.e.:


=COUNTIF(A:A,"")


will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")


Hope this helps.


Pete


On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds
zero?
--
jake- Hide quoted text -


- Show quoted text -


  #18  
Old June 22nd, 2008, 07:07 PM posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\)[_731_]
external usenet poster
 
Posts: 1
Default Counting Items

Ignore my previous post... I quite stupidly replaced the X with a 2 in the
data column's formula and left the rest of it alone when I tested Biff's
formula; however, I left the surrounding quote marks so the 2 was encased in
quotes when I tested Biff's formula (that is, the 2 was a text 2, not a
numerical 2, hence his formula appeared to work with numbers when in reality
it doesn't).

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Biff's formula worked for me with either text or numbers. What formula are
you using in your cells (I'd like to see why you are saying it doesn't
work for you)?

Rick


"Jakobshavn Isbrae" wrote in
message ...
Thank you very much for taking the time to offer help. The formula seems
to
ignore numbers.
--
jake


"T. Valko" wrote:

Try this:

=COUNTIF(A1:A10,"?*")

--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote
in
message ...
I put this formula in A1...

=IF(MOD(ROW(A1),3),"X","")

and copied it down to A10. On my copy of XL2003, your formula, as well
as
the other formulas that were posted (except for mine, of courseg),
returns 10 instead of 7 meaning it counted the blank (looking) cells
as
well as the non-blank looking ones.

Rick


"Pete_UK" wrote in message
...
Try using COUNTIF, i.e.:

=COUNTIF(A:A,"")

will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")

Hope this helps.

Pete

On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds
zero?
--
jake






  #19  
Old June 22nd, 2008, 07:11 PM posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\)[_732_]
external usenet poster
 
Posts: 1
Default Counting Items

Thanks... I had forgotten to take in account the array aspect of SUMPRODUCT.

Rick


"T. Valko" wrote in message
...
I'm guessing the answer will probably be "yes"


You are correct.

One of the biggest reasons and one that folks don't seem to consider is
that since SP works on arrays it evaluates *every* reference in the array
arguments.

=COUNTIF(A:A,"X")

Is very efficient because COUNTIF will only evaluate the used range.

=SUMPRODUCT(--(A1:A1000="x"))

Will evaluate every cell in A1:A1000 even if the used range only goes to
A100.

In Excel 2007:

=SUMPRODUCT(--(A:A="x"))

Is "crazy"!

I was more interested in its "scale of slowness" as opposed to the simple
fact that it is slower.


There is code here to test calculation times:

http://msdn2.microsoft.com/en-us/library/aa730921.aspx


--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote in
message ...
Yes, of course, wildcards... that works fine.

I find my inclination is to go to the SUMPRODUCT function because of it
vast flexibility as a calculation engine. I was wondering if you knew (or
if anyone else reading this message knows) whether the SUMPRODUCT is, by
its very nature as a universal type calculation engine, a necessarily
slow function compared to the more targeted functions (such as your
COUNTIF formula compared to my SUMPRODUCT formula)? I'm guessing the
answer will probably be "yes", but I was more interested in its "scale of
slowness" as opposed to the simple fact that it is slower.

Rick


"T. Valko" wrote in message
...
Try this:

=COUNTIF(A1:A10,"?*")

--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote
in message ...
I put this formula in A1...

=IF(MOD(ROW(A1),3),"X","")

and copied it down to A10. On my copy of XL2003, your formula, as well
as the other formulas that were posted (except for mine, of courseg),
returns 10 instead of 7 meaning it counted the blank (looking) cells as
well as the non-blank looking ones.

Rick


"Pete_UK" wrote in message
...
Try using COUNTIF, i.e.:

=COUNTIF(A:A,"")

will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")

Hope this helps.

Pete

On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds
zero?
--
jake







  #20  
Old June 22nd, 2008, 07:12 PM posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\)[_733_]
external usenet poster
 
Posts: 1
Default Counting Items

Thanks... as Biff pointed out, the slowness resides in the array aspect of
SUMPRODUCT.

Rick


"Pete_UK" wrote in message
...
Rick,

SUMIF and COUNTIF are much faster than SUMPRODUCT (or SUM(IF .. )
array formula) equivalents when you have a lot of rows. I analyse
telephone data for clients, where we might have 40,000 call records a
month (or more), and I have shown (to myself) that SP formulae are
much slower. It often pays to join several columns together and do a
SUMIF on the concatenated values rather than have SP with lots of
criteria in them (eg calls made of a particular type in a particular
charging period from a particular phone number between two particular
dates - you end up with 5 SP criteria each of 40,000 rows, whereas by
concatenating them together allows SUMIF to scan through just one
array).

Pete

On Jun 22, 6:14 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Yes, of course, wildcards... that works fine.

I find my inclination is to go to the SUMPRODUCT function because of it
vast
flexibility as a calculation engine. I was wondering if you knew (or if
anyone else reading this message knows) whether the SUMPRODUCT is, by its
very nature as a universal type calculation engine, a necessarily slow
function compared to the more targeted functions (such as your COUNTIF
formula compared to my SUMPRODUCT formula)? I'm guessing the answer will
probably be "yes", but I was more interested in its "scale of slowness" as
opposed to the simple fact that it is slower.

Rick

"T. Valko" wrote in message

...



Try this:


=COUNTIF(A1:A10,"?*")


--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote
in
. ..
I put this formula in A1...


=IF(MOD(ROW(A1),3),"X","")


and copied it down to A10. On my copy of XL2003, your formula, as well
as
the other formulas that were posted (except for mine, of courseg),
returns 10 instead of 7 meaning it counted the blank (looking) cells as
well as the non-blank looking ones.


Rick


"Pete_UK" wrote in message
...
Try using COUNTIF, i.e.:


=COUNTIF(A:A,"")


will count everything in column A which is not blank (or appears to be
blank, like a formula returning "")


Hope this helps.


Pete


On Jun 22, 4:16 pm, Jakobshavn Isbrae
wrote:
How can I count the number of items in a column whose length exceeds
zero?
--
jake- Hide quoted text -


- Show quoted text -


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.