Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Concatenating A Unique Number

If my data looks like the following -

StudentID School Year CourseID CourseName
724260 2000-2001 8881 PE
724260 2000-2001 8881 PE
697660 2001-2002 8891 PE
697660 2001-2002 8891 PE
697660 2001-2002 8891 PE

I would like to make each record unique by addling a number to the
CourseID so that I'd end up with:

StudentID School Year CourseID CourseName
724260 2000-2001 8881-1 PE
724260 2000-2001 8881-2 PE
697660 2001-2002 8891-1 PE
697660 2001-2002 8891-2 PE
697660 2001-2002 8891-3 PE

How can I do this?

Thank you,

Sheldon Potolsky

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default Concatenating A Unique Number

On Fri, 23 Jan 2009 11:26:18 -0800 (PST), Sheldon Potolsky
wrote:

If my data looks like the following -

StudentID School Year CourseID CourseName
724260 2000-2001 8881 PE
724260 2000-2001 8881 PE
697660 2001-2002 8891 PE
697660 2001-2002 8891 PE
697660 2001-2002 8891 PE

I would like to make each record unique by addling a number to the
CourseID so that I'd end up with:

StudentID School Year CourseID CourseName
724260 2000-2001 8881-1 PE
724260 2000-2001 8881-2 PE
697660 2001-2002 8891-1 PE
697660 2001-2002 8891-2 PE
697660 2001-2002 8891-3 PE

How can I do this?

Thank you,

Sheldon Potolsky


If your data is in columns A thru D, you can get a column with unique
Course ID in column E by this formula in cell E2:

=C2&"-"&(SUMPRODUCT((C$1:C1=C2)*(A$1:A1=A2)*(B$1:B1=B2)* (D$1:D1=D2))+1)

Copy down as far as you have data.

The first parenthesis (C1$:C1=C2) should always be there.
The other parenthesis you can add if needed (your example does not
show if different student ID' or different School years can have the
same Course ID).

Hope this helps / Lars-Åke
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default Concatenating A Unique Number

Hello,

Why not just
=C2&"-"&COUNTIF(C$2:C2,C2)
and copy down?

Regards,
Bernd
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default Concatenating A Unique Number

On Fri, 23 Jan 2009 12:39:14 -0800 (PST), Bernd P
wrote:

Hello,

Why not just
=C2&"-"&COUNTIF(C$2:C2,C2)
and copy down?

Regards,
Bernd


From the example given it is not clear if there could be
the same course ID for different student ID's (or different school
years) and, if so, the unique course ID should be "globally unique" or
just unique for each student ID.

Lars-Åke


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default Concatenating A Unique Number

Hello Lars-Åke,

Ok, you are right if local uniqueness is required.

But then I would suggest to use
=C2&"-"&SUMPRODUCT((C$2:C2=C2)*(A$2:A2=A2)*(B$2:B2=B2)*( D$2:D2=D2))
or even
=C2&"-"&SUMPRODUCT((C$2:C2=C2)*(A$2:A2=A2)*(B$2:B2=B 2))

Regards,
Bernd


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default Concatenating A Unique Number

On Sat, 24 Jan 2009 03:38:27 -0800 (PST), Bernd P
wrote:

Hello Lars-Åke,

Ok, you are right if local uniqueness is required.

But then I would suggest to use
=C2&"-"&SUMPRODUCT((C$2:C2=C2)*(A$2:A2=A2)*(B$2:B2=B2)*( D$2:D2=D2))
or even
=C2&"-"&SUMPRODUCT((C$2:C2=C2)*(A$2:A2=A2)*(B$2:B2=B 2))

Regards,
Bernd


Yes, that is a bit simpler :-) / Lars-Åke
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding unique names--then converting those names to unique number Proton Excel Discussion (Misc queries) 7 June 13th 07 10:22 PM
Appending / Concatenating by Client Number Dina Excel Programming 0 June 8th 07 04:23 PM
Date column changed to number format while concatenating Biju Jacob Excel Discussion (Misc queries) 1 June 12th 06 07:07 PM
concatenating a number plus a formatted number childothe1980s Excel Programming 4 March 4th 06 11:46 PM
concatenating and formatting area code and phone number columns sherri Excel Worksheet Functions 4 September 1st 05 09:59 PM


All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"