Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default a twist on counting unique values in a range which contains blankcells, using a formula. the formula can't use SUMPRODUCT or FREQUENCY

I need a formula, not VB code, to count the number of unique values in a column of up to 10,000 rows, some of which will be blank. The values may be numeric, alphanumberic, or text.

The twist is that the formula can't use either the SUMPRODUCT or the FREQUENCY functions. The excel handler which processes the file for a database can't handle SUMPRODUCT or FREQUENCY.

I got very close with this array formula: =SUM(1/COUNTIF(A1:A36,A22:A36)) But as you can see it has to be limited to the range of nonblank cells, since it throws a #DIV/0 error if the range includes blank cells.

I've made some unsuccessful attempts at using COUNTIFS with criteria for only nonblank cells.

Any ideas?

Thanks in advance!

pete
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default a twist on counting unique values in a range which contains blankcells, using a formula. the formula can't use SUMPRODUCT or FREQUENCY

hi,

=COUNTIF(A1:A65535,A1:A65535)-1

isabelle

Le 2016-08-04 Ã* 09:24, pete a écrit :
I need a formula, not VB code, to count the number of unique values in a
column of up to 10,000 rows, some of which will be blank. The values may be
numeric, alphanumberic, or text.

The twist is that the formula can't use either the SUMPRODUCT or the
FREQUENCY functions. The excel handler which processes the file for a
database can't handle SUMPRODUCT or FREQUENCY.

I got very close with this array formula: =SUM(1/COUNTIF(A1:A36,A22:A36))
But as you can see it has to be limited to the range of nonblank cells, since
it throws a #DIV/0 error if the range includes blank cells.

I've made some unsuccessful attempts at using COUNTIFS with criteria for only
nonblank cells.

Any ideas?

Thanks in advance!

pete

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default a twist on counting unique values in a range which contains blank cells, using a formula. the formula can't use SUMPRODUCT or FREQUENCY

Hi Pete,

Am Thu, 4 Aug 2016 06:24:17 -0700 (PDT) schrieb pete:

I need a formula, not VB code, to count the number of unique values in a column of up to 10,000 rows, some of which will be blank. The values may be numeric, alphanumberic, or text.


try:
=SUM(IF(A1:A36<"",1/COUNTIF(A1:A36,A1:A36)))
and insert the formula with CTRL+Shift+Enter


Regards
Claus B.
--
Windows10
Office 2016
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default a twist on counting unique values in a range which contains blank cells, using a formula. the formula can't use SUMPRODUCT or FREQUENCY

Hi Pete,

Am Thu, 4 Aug 2016 17:40:47 +0200 schrieb Claus Busch:

=SUM(IF(A1:A36<"",1/COUNTIF(A1:A36,A1:A36)))


if you have a lot of rows the array formula is very slow.
Try this UDF:

Function UniqueVals(myRng As Range) As Long
Dim myDic As Object
Dim varTmp As Variant, varData As Variant
Dim i As Long, Counter As Long

Set myDic = CreateObject("Scripting.Dictionary")
varTmp = myRng
For i = LBound(varTmp) To UBound(varTmp)
myDic(varTmp(i, 1)) = varTmp(i, 1)
Next
varData = myDic.items
For i = LBound(varData) To UBound(varData)
If varData(i) < "" Then Counter = Counter + 1
Next
UniqueVals = Counter
End Function

Call it in the worksheet with
=UniqueVals(A1:A10000)


Regards
Claus B.
--
Windows10
Office 2016
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default a twist on counting unique values in a range which contains blankcells, using a formula. the formula can't use SUMPRODUCT or FREQUENCY

On Thursday, August 4, 2016 at 8:30:43 AM UTC-7, isabelle wrote:
hi,

=COUNTIF(A1:A65535,A1:A65535)-1

isabelle

Le 2016-08-04 Ã* 09:24, pete a écrit :
I need a formula, not VB code, to count the number of unique values in a
column of up to 10,000 rows, some of which will be blank. The values may be
numeric, alphanumberic, or text.

The twist is that the formula can't use either the SUMPRODUCT or the
FREQUENCY functions. The excel handler which processes the file for a
database can't handle SUMPRODUCT or FREQUENCY.

I got very close with this array formula: =SUM(1/COUNTIF(A1:A36,A22:A36))
But as you can see it has to be limited to the range of nonblank cells, since
it throws a #DIV/0 error if the range includes blank cells.

I've made some unsuccessful attempts at using COUNTIFS with criteria for only
nonblank cells.

Any ideas?

Thanks in advance!

pete


Thanks Isabelle!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default a twist on counting unique values in a range which contains blankcells, using a formula. the formula can't use SUMPRODUCT or FREQUENCY

On Thursday, August 4, 2016 at 8:40:51 AM UTC-7, Claus Busch wrote:
Hi Pete,

Am Thu, 4 Aug 2016 06:24:17 -0700 (PDT) schrieb pete:

I need a formula, not VB code, to count the number of unique values in a column of up to 10,000 rows, some of which will be blank. The values may be numeric, alphanumberic, or text.


try:
=SUM(IF(A1:A36<"",1/COUNTIF(A1:A36,A1:A36)))
and insert the formula with CTRL+Shift+Enter


Regards
Claus B.
--
Windows10
Office 2016


Thanks Claus!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula for counting frequency then sorting J.Scargill[_2_] Excel Worksheet Functions 5 April 7th 10 04:34 PM
Counting the number of unique values within a range SiH23 Excel Discussion (Misc queries) 5 October 30th 08 07:36 PM
Counting Unique Values by Date Range [email protected] Excel Worksheet Functions 5 August 2nd 07 09:36 PM
Counting unique values + frequency Mike Ferguson Excel Worksheet Functions 3 November 24th 04 08:31 AM
Counting Unique Entries Wit a Twist Minitman[_4_] Excel Programming 6 November 11th 04 07:35 AM


All times are GMT +1. The time now is 12:02 AM.

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

About Us

"It's about Microsoft Excel"