ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Counting Occurrance of # In Range (https://www.excelbanter.com/excel-discussion-misc-queries/205186-counting-occurrance-range.html)

AB

Counting Occurrance of # In Range
 
I have a range of #s and I want to count the first occurrence of each number.
I used CountIf but I received false results. See the example below. The
results for 300 should have been 3 for each occurrence. But I would prefer
to have 3 for the first occurrence of 300 and 0 for the 2nd and 3rd
occurrence. Help.

Column A Results
10 1
15 1
300 3
300 2
300 1
20 2
20 1


Mike H

Counting Occurrance of # In Range
 
Hi,

the range address must be absolute to get the result you want

=COUNTIF($A$1:$A$7,A1)

Mike

"AB" wrote:

I have a range of #s and I want to count the first occurrence of each number.
I used CountIf but I received false results. See the example below. The
results for 300 should have been 3 for each occurrence. But I would prefer
to have 3 for the first occurrence of 300 and 0 for the 2nd and 3rd
occurrence. Help.

Column A Results
10 1
15 1
300 3
300 2
300 1
20 2
20 1


Ken Johnson

Counting Occurrance of # In Range
 
On Oct 7, 12:02*am, AB wrote:
I have a range of #s and I want to count the first occurrence of each number.
*I used CountIf but I received false results. *See the example below. *The
results for 300 should have been 3 for each occurrence. *But I would prefer
to have 3 for the first occurrence of 300 and 0 for the 2nd and 3rd
occurrence. *Help.

Column A * * * *Results
10 * * *1
15 * * *1
300 * * 3
300 * * 2
300 * * 1
20 * * *2
20 * * *1


Try...

=COUNTIF($A$1:$A$7,A1)*IF(COUNTIF($A$1:A1,A1)1,0, 1)

Ken Johnson


All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com