How can I number rows based on unique values in another column?

C

Carla

I need to create a number in column A based on the data in column B. Here's
an example of the result that I want:

Number Product Code
1 001-1002-P
1 001-1002-R
1 003-4501-10
2 003-4501-10
1 003-4501-12
2 003-4501-12
1 003-4501-14
2 003-4501-14

I'm really looking to get either a 1 or 2 based on the first or 2nd entry of
the product code.
 
J

Jacob Skaria

Try the below formula in cell A2 and copy down as required
=COUNTIF($B$2:B2,B2)
 
M

Max

Assuming data starts in B2 down
Put in A2: =COUNTIF(B$2:B2,B2)
Copy down. Success? hit the YES below
 
L

Lars-Åke Aspelin

I need to create a number in column A based on the data in column B. Here's
an example of the result that I want:

Number Product Code
1 001-1002-P
1 001-1002-R
1 003-4501-10
2 003-4501-10
1 003-4501-12
2 003-4501-12
1 003-4501-14
2 003-4501-14

I'm really looking to get either a 1 or 2 based on the first or 2nd entry of
the product code.

Try this formula in cell A2:

=COUNTIF(B$2:B2,B2)

Copy down as far as you have data in column B.

If the prioducts are alway grouped together according to the product
codes, as in your example, this formula could alternatively be used:

=COUNTIF(B1:B2,B2)

Hope this helps / Lars-Åke
 
T

T. Valko

I'm really looking to get either a 1 or 2 based
on the first or 2nd entry of the product code.

Assuming the data is sorted as is shown in the posted sample and there are
no gaps in the data (empty cells).

Enter this formula in A2 and copy down as needed:

=(B2=B1)+1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top