# Count what Instance an Occurance is

#### TheRogue!

##### Board Regular
I've got a table. The headers for the table are individuals.
The first data row of the table is what group the individuals are in (either Red or Blue).

On the next row of data, in the table, I need it to count what instance the occurance is (not the total number of occurances).
The first time it comes accross the value Blue in the data it needs to report "1", the next time it comes across "Blue", "2" & so on.

I know that there are 5 people in the Red group & 4 in the Blue group, so COUNTIF doesn't help me. I need it to number the people in the Red group 1-5 & the people in the Blue group 1-4.

It is also possible that the data in the group row will change (someone from Blue may go to Red), so I need to do this dynamically, w/ a formula.

Example:
 STAN EARL JIM CATHY LIZ MURRAY LISA ELI PETE 1 BLUE BLUE RED RED BLUE RED RED RED BLUE 2 1 2 1 2 3 3 4 5 4 3 4 5 6

<COLGROUP><COL style="WIDTH: 48pt" span=10 width=64><TBODY>
</TBODY>

### Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

#### Scott Huish

##### MrExcel MVP
In A3:
=COUNTIF(\$A2:A2,A2)

Copy across.

Excel Workbook
ABCDEFGHI
1STANEARLJIMCATHYLIZMURRAYLISAELIPETE
2BLUEBLUEREDREDBLUEREDREDREDBLUE
3121233454
Sheet1

#### njimack

##### Well-known Member
I don't understand why COUNTIF won't suffice?

Excel Workbook
ABCDEFGHI
1STANEARLJIMCATHYLIZMURRAYLISAELIPETE
2BLUEBLUEREDREDBLUEREDREDREDBLUE
3121233454
Sheet1

#### TheRogue!

##### Board Regular
Found my answer, elsewhere - I wasn't using the COUNTIF function correctly.
The correct usage is: =COUNTIF(\$C\$2:C\$2,C\$2) Copy across.

Just in case anyone else needs it.

Replies
5
Views
279
Replies
6
Views
266
Replies
2
Views
82
Replies
8
Views
111
Replies
0
Views
284

1,196,017
Messages
6,012,872
Members
441,737
Latest member
bijayche

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back