Create numbering sequence within groups

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,368
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I'm currently using =IF(B1=B2,C1,MAX($C$1:C1)+1) in column C and it works fine to establish a sequential numbering, but not sure how to adjust for a new year.

Data Range
[TABLE="class: grid"]
<tbody>[TR]
[TD][/TD]
[TD]
A​
[/TD]
[TD]
B​
[/TD]
[TD]
C​
[/TD]
[/TR]
[TR]
[TD]
1​
[/TD]
[TD]
Year​
[/TD]
[TD]
Team​
[/TD]
[TD]
Series​
[/TD]
[/TR]
[TR]
[TD]
2​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team1​
[/TD]
[TD]
1​
[/TD]
[/TR]
[TR]
[TD]
3​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team1​
[/TD]
[TD]
1​
[/TD]
[/TR]
[TR]
[TD]
4​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team1​
[/TD]
[TD]
1​
[/TD]
[/TR]
[TR]
[TD]
5​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
6​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
7​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
8​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
9​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
10​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
11​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
12​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
13​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team1​
[/TD]
[TD]
4​
[/TD]
[/TR]
[TR]
[TD]
14​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team1​
[/TD]
[TD]
4​
[/TD]
[/TR]
[TR]
[TD]
15​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
5​
[/TD]
[/TR]
[TR]
[TD]
16​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
5​
[/TD]
[/TR]
[TR]
[TD]
17​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
5​
[/TD]
[/TR]
[TR]
[TD]
18​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
5​
[/TD]
[/TR]
[TR]
[TD]
19​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
5​
[/TD]
[/TR]
[TR]
[TD]
20​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team3​
[/TD]
[TD]
6​
[/TD]
[/TR]
[TR]
[TD]
21​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team3​
[/TD]
[TD]
6​
[/TD]
[/TR]
[TR]
[TD]
22​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team3​
[/TD]
[TD]
6​
[/TD]
[/TR]
[TR]
[TD]
23​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team3​
[/TD]
[TD]
6​
[/TD]
[/TR]
</tbody>[/TABLE]

Would like
Data Range
[TABLE="class: grid"]
<tbody>[TR]
[TD][/TD]
[TD]
A​
[/TD]
[TD]
B​
[/TD]
[TD]
C​
[/TD]
[/TR]
[TR]
[TD]
1​
[/TD]
[TD]
Year​
[/TD]
[TD]
Team​
[/TD]
[TD]
Series​
[/TD]
[/TR]
[TR]
[TD]
2​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team1​
[/TD]
[TD]
1​
[/TD]
[/TR]
[TR]
[TD]
3​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team1​
[/TD]
[TD]
1​
[/TD]
[/TR]
[TR]
[TD]
4​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team1​
[/TD]
[TD]
1​
[/TD]
[/TR]
[TR]
[TD]
5​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
6​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
7​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
8​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
9​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
10​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
11​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
12​
[/TD]
[TD]
2018​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
13​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team1​
[/TD]
[TD]
1​
[/TD]
[/TR]
[TR]
[TD]
14​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team1​
[/TD]
[TD]
1​
[/TD]
[/TR]
[TR]
[TD]
15​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
16​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
17​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
18​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
19​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team2​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
20​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
21​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
22​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
23​
[/TD]
[TD]
2019​
[/TD]
[TD]
Team3​
[/TD]
[TD]
3​
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about:
Code:
[COLOR=#333333]=IF(A1<>A2,1,IF(B1=B2,C1,MAX($C$1:C1)+1))[/COLOR]
 
Upvote 0
Hi Joe and thanks. That we my first thought, but that only changes the first grouping after the new year. After that the max is used.

Data Range
[Table="class: grid"][tr][td] [/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][/tr]
[tr][td]
1​
[/td][td]
Year​
[/td][td]
Team​
[/td][td]
Series​
[/td][/tr]
[tr][td]
2​
[/td][td]
2018​
[/td][td]
Team1​
[/td][td]
1​
[/td][/tr]
[tr][td]
3​
[/td][td]
2018​
[/td][td]
Team1​
[/td][td]
1​
[/td][/tr]
[tr][td]
4​
[/td][td]
2018​
[/td][td]
Team1​
[/td][td]
1​
[/td][/tr]
[tr][td]
5​
[/td][td]
2018​
[/td][td]
Team2​
[/td][td]
2​
[/td][/tr]
[tr][td]
6​
[/td][td]
2018​
[/td][td]
Team2​
[/td][td]
2​
[/td][/tr]
[tr][td]
7​
[/td][td]
2018​
[/td][td]
Team2​
[/td][td]
2​
[/td][/tr]
[tr][td]
8​
[/td][td]
2018​
[/td][td]
Team2​
[/td][td]
2​
[/td][/tr]
[tr][td]
9​
[/td][td]
2018​
[/td][td]
Team3​
[/td][td]
3​
[/td][/tr]
[tr][td]
10​
[/td][td]
2018​
[/td][td]
Team3​
[/td][td]
3​
[/td][/tr]
[tr][td]
11​
[/td][td]
2018​
[/td][td]
Team3​
[/td][td]
3​
[/td][/tr]
[tr][td]
12​
[/td][td]
2018​
[/td][td]
Team1​
[/td][td]
4​
[/td][/tr]
[tr][td]
13​
[/td][td]
2018​
[/td][td]
Team1​
[/td][td]
4​
[/td][/tr]
[tr][td]
14​
[/td][td]
2018​
[/td][td]
Team1​
[/td][td]
4​
[/td][/tr]
[tr][td]
15​
[/td][td]
2019​
[/td][td]
Team1​
[/td][td]
1​
[/td][/tr]
[tr][td]
16​
[/td][td]
2019​
[/td][td]
Team1​
[/td][td]
1​
[/td][/tr]
[tr][td]
17​
[/td][td]
2019​
[/td][td]
Team2​
[/td][td]
5​
[/td][/tr]
[tr][td]
18​
[/td][td]
2019​
[/td][td]
Team2​
[/td][td]
5​
[/td][/tr]
[tr][td]
19​
[/td][td]
2019​
[/td][td]
Team2​
[/td][td]
5​
[/td][/tr]
[tr][td]
20​
[/td][td]
2019​
[/td][td]
Team2​
[/td][td]
5​
[/td][/tr]
[tr][td]
21​
[/td][td]
2019​
[/td][td]
Team2​
[/td][td]
5​
[/td][/tr]
[tr][td]
22​
[/td][td]
2019​
[/td][td]
Team3​
[/td][td]
6​
[/td][/tr]
[tr][td]
23​
[/td][td]
2019​
[/td][td]
Team3​
[/td][td]
6​
[/td][/tr]
[tr][td]
24​
[/td][td]
2019​
[/td][td]
Team3​
[/td][td]
6​
[/td][/tr]
[tr][td]
25​
[/td][td]
2019​
[/td][td]
Team3​
[/td][td]
6​
[/td][/tr]
[/table]
 
Upvote 0
Actually, you do not need to use MAX at all. Since they are only ever increasing by 1 based on the previous value, just use:
Code:
=IF(A1<>A2,1,IF(B1=B2,C1,C1+1))
 
Upvote 0
Actually, you do not need to use MAX at all. Since they are only ever increasing by 1 based on the previous value, just use:
Code:
[COLOR=#333333]=IF(A1<>A2,1,IF(B1=B2,C1,C1+1))[/COLOR]

Is it possible to get this formula to restart after 20 rows
 
Upvote 0
Is it possible to get this formula to restart after 20 rows
That really complicates it a bit, and really is a question deserving of its own thread (instead of tacking on to an old, existing one posted by someone else).
You will get more people looking at it too, if it is in a new, unanswered thread.

Be sure to be detailed in your question, and include screen prints of the data, so people can see exactly what you are working with and what you would like to happen.
 
Upvote 0

Forum statistics

Threads
1,224,738
Messages
6,180,673
Members
452,993
Latest member
FDARYABEE

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top