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 |
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 |
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 |
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 |
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! |
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! |
All times are GMT +1. The time now is 03:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com