Assigning a value based on number of appearances

Datalipps

New Member
Joined
Jul 14, 2011
Messages
2
Example: I'm trying to assign a value based on the order a field appears in a column. If my original data set is column A, my desired result would be column 'B'. I think I need a CSE formula. Thanks in advance.

Column A - Column B
Dan - 1
Dan - 2
Dan - 3
Earl - 1
Earl - 2
Jim - 1
Matt - 1
Matt - 2
Matt - 3
Kyle - 1
Kyle - 2
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Example: I'm trying to assign a value based on the order a field appears in a column. If my original data set is column A, my desired result would be column 'B'. I think I need a CSE formula. Thanks in advance.

Column A - Column B
Dan - 1
Dan - 2
Dan - 3
Earl - 1
Earl - 2
Jim - 1
Matt - 1
Matt - 2
Matt - 3
Kyle - 1
Kyle - 2
Try this...

Book1
AB
2Dan1
3Dan2
4Dan3
5Earl1
6Earl2
7Jim1
8Matt1
9Matt2
10Matt3
11Kyle1
12Kyle2
Sheet1

This formula entered in B2 and copied down:

=COUNTIF(A$2:A2,A2)
 
Upvote 0
that's genius. I never thought about NOT hardcoding the row... Now I feel silly.
Using that method is OK as long as you don't have 10's of 1000's of rows of data.

For very large data sets you could do this...

Enter 1 in B2.

Enter this formula in B3 and copy down to the end of data:

=IF(A3=A2,B2+1,1)
 
Upvote 0
Yes, the data will be sorted. It would be interesting to know how to do that w/o sorting the data and having it referencing a date field but I'll tackle that on the next revision.

Thanks for all of the help, I'm embarrassed it was that easy!
 
Upvote 0
Yes, the data will be sorted. It would be interesting to know how to do that w/o sorting the data and having it referencing a date field but I'll tackle that on the next revision.

Thanks for all of the help, I'm embarrassed it was that easy!
You're welcome. Thanks for the feedback! :cool:
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,267
Members
452,902
Latest member
Knuddeluff

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