Creating a custom sequence based on another cell

What formula or function can I use to populate a number based on how often a number appears in another column.  I want it to say 1, 2, or 3 and keep that order.  If it is the 5th time a number appears in column B, I want the number to show 2.
E. J.Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Why not upload a sample workbook with the desired output mocked up manually to visualize your requirement?
Rob HensonFinance AnalystCommented:
With your range of numbers starting in B2, use formula in C2 and copy down as required:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rob HensonFinance AnalystCommented:
In case you are not aware, the MOD function works as follows.

Syntax = MOD(Number, Divider)

The function will divide the number by the Divider and will return the remainder. So in your scenario, I have used it for dividing the count of the number by 3.

The results will be:

Count = 1 gives 1 divided by 3 equals zero remainder 1
Count = 2 gives 2 divided by 3 equals zero remainder 2
Count = 3 gives 3 divided by 3 equals 1 remainder 0, so forced to a 3 in the formula
Count = 4 gives 4 divided by 3 equals 1 remainder 1
etc etc counts that divide by 3 exactly will have result of zero so forced to a 3, counts that don't divide by 3 will be either 1 or 2.

Hope that explains it.

Rob HensonFinance AnalystCommented:
Without confirmatio  from author but does as requested
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.