Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / October 2006

Tip: Looking for answers? Try searching our database.

Countif array formula

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 17 Oct 2006 10:06 GMT
Greetings,
I have range A1:A5 i need to test for repeating cell contents
Array formula =countif($A$1:$A$5,A1:A5) works fine and for cell contents:
A,A,B,C,D returns: 2,2,1,1,1
Now I wish to test for repeating leftmost characters, ie for cell contents:
AF,DT,PQ,AS,AD i need to return: 3,1,1,3,3
I've tried: =countif(LEFT($A$1:$A$5),LEFT(A1:A5)) entered as array formula
but returns an error
Please advise
Thanks
vezerid - 17 Oct 2006 11:18 GMT
David,

COUNTIF only accepts range refs in the 1st argument and not virtual
arrays. You will need to use SUMPRODUCT for this:

=SUMPRODUCT(--(LEFT($A$1:$A$5)=LEFT(A1)))

No array-entering now, just copy downwards.

Does this help?
Kostis Vezerides

> Greetings,
> I have range A1:A5 i need to test for repeating cell contents
[quoted text clipped - 6 lines]
> Please advise
> Thanks
David - 17 Oct 2006 13:05 GMT
Thanks vezerid,
much appreciated

> David,
>
[quoted text clipped - 18 lines]
> > Please advise
> > Thanks
Leo Heuser - 17 Oct 2006 11:20 GMT
> Greetings,
> I have range A1:A5 i need to test for repeating cell contents
[quoted text clipped - 7 lines]
> Please advise
> Thanks

Hi David

One way:

=MMULT((LEFT(A1:A5)=TRANSPOSE(LEFT(A1:A5)))+0,(LEFT(A1:A5)=LEFT(A1:A5))+0)

To be entered with <Shift><Ctrl><Enter>

COUNTIF() can only be used on a range, not on an array and
LEFT($A$1:$A$5) is an array.

Signature

Best regards
Leo Heuser

Followup to newsgroup only please.

David - 17 Oct 2006 13:09 GMT
Thanks Leo,
I look forward to trying both solutions tonight. My finished app will run
this many 1000s of times. - It'll be interesting to see how this compares to
the other solution on performance
Thanks again

> > Greetings,
> > I have range A1:A5 i need to test for repeating cell contents
[quoted text clipped - 18 lines]
> COUNTIF() can only be used on a range, not on an array and
> LEFT($A$1:$A$5) is an array.
vezerid - 17 Oct 2006 13:34 GMT
And please inform us of the comparison results.

Regards,
Kostis

> Thanks Leo,
> I look forward to trying both solutions tonight. My finished app will run
> this many 1000s of times. - It'll be interesting to see how this compares to
> the other solution on performance
> Thanks again
vezerid - 17 Oct 2006 13:28 GMT
Wow Leo, that was a good one. Definitely saved in my bag of tricks.

Kostis
Leo Heuser - 17 Oct 2006 16:29 GMT
> Wow Leo, that was a good one. Definitely saved in my bag of tricks.
>
> Kostis

Thanks, Kostis :-)

Leo Heuser
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.