Code to add numbering to cells based on another cell

All

In column A have names of books; column  B name of author and need to add in column C numbers 1,2,3,4 etc - see below example

the cat        John  Smith  1
the cat        Mary Johns   2
the dog       David Brown  1
the fish       Sue Stone     1
the fish       Peter Smith   2

any ideas on code for this one

TIA

Shaz
shaz0503Asked:
Who is Participating?

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

x
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.

zorvek (Kevin Jones)ConsultantCommented:
In cell C2 place a "1".

In cell C3 place this formula:

   =IF(A3=A2,C2+1,1)

and copy down and as far as necessary.

Kevin

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
shaz0503Author Commented:
Thanks you so much - as per usual seems so easy when the answer is in front of you.

rgds

Shaz
Patrick MatthewsCommented:
shaz0503,

Just in case your data are not sorted by book name, and if "the cat" were to reappear 50 rows later you would want the numbering to stay continuous and not restart at 1, put this formula in C2:

=COUNTIF(A$2:A2,A2)

and copy down as needed.

If you would want to restart the numbering in such a case, then Kevin's suggestion is perfect.

:)

Patrick
shaz0503Author Commented:

Thanks Patrick - will keep this in mind for future reference.....

rgds

Shaz
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.