A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old January 7th, 2010, 05:37 AM posted to microsoft.public.excel.worksheet.functions
Carla
external usenet poster
 
Posts: 166
Default How can I number rows based on unique values in another column?

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.
--
Carla
  #2  
Old January 7th, 2010, 05:47 AM posted to microsoft.public.excel.worksheet.functions
Jacob Skaria
external usenet poster
 
Posts: 5,952
Default How can I number rows based on unique values in another column?

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

--
Jacob


"Carla" wrote:

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

  #3  
Old January 7th, 2010, 05:49 AM posted to microsoft.public.excel.worksheet.functions
Max
external usenet poster
 
Posts: 8,574
Default How can I number rows based on unique values in another column?

Assuming data starts in B2 down
Put in A2: =COUNTIF(B$2:B2,B2)
Copy down. Success? hit the YES below
--
Max
Singapore
---
"Carla" wrote:
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.
--
Carla

  #4  
Old January 7th, 2010, 05:56 AM posted to microsoft.public.excel.worksheet.functions
Lars-Åke Aspelin[_2_]
external usenet poster
 
Posts: 722
Default How can I number rows based on unique values in another column?

On Wed, 6 Jan 2010 21:37:02 -0800, Carla
wrote:

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

  #5  
Old January 7th, 2010, 06:03 AM posted to microsoft.public.excel.worksheet.functions
T. Valko
external usenet poster
 
Posts: 15,759
Default How can I number rows based on unique values in another column?

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

--
Biff
Microsoft Excel MVP


"Carla" wrote in message
...
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.
--
Carla



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:31 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.