3
votes

I am attempting to generate 8 digit serial numbers with Excel based on the following:

ABCDEFGH
  • A = Value in column C (User Specified)
  • BC = YEAR (Which I have in hidden column)
  • D using = RIGHT(YEAR(A3), 2) where A3 is date entered.
  • DE = Week in Year (Which I have in hidden column
  • E using =WEEKNUM(A3).
  • FGH = Sequential numbers from 001 to 999.

This is the part I can't figure out. I want the first serial number for each week to be 001 and run until the week changes. Serial number will then start over at 001 with the new week. Eventually I want to nest all of the formulas into one cell but for now I can just hide the columns until I can grasp the whole thing.

Here's an example:

Date | Customer | User Specified | Year | Week | Serial
11/14/2013 | Sample_Customer | "5" | 13 | 46 | 51346001
11/14/2013 | Sample_Customer | "5" | 13 | 46 | 51346002
11/14/2013 | Sample_Customer2 | "5" | 13 | 46 | 51346003
12/24/2013 | Sample_Customer3 | "3" | 13 | 52 | 31352001

The serial number (column F) should generate once I place the date into the A column.

2

2 Answers

3
votes

Try this:

Get rank for the week number and add rownumber: G2=RANK(E2,$E$2:$E$5)+ROW()

Rank, group by week number: H2=SUMPRODUCT(($E$2:$E$5=E2)*($G$2:$G$5<G2))+1

Make 3 digit serial number: I2=RIGHT("000"&H2,3)

enter image description here

1
votes

to generate the last three digits of the serial number you can use the following (assuming this is going in column G which I will call Seq No. and the data starts in row 2 and I am creating the three digit serial in G4

I am also assuming the year value is in column D and the week number is in column E.

=IF(COUNTIFS($D$2:D13,D14,$E$2:E13,E14)<9,"00",IF(COUNTIFS($D$2:D13,D14,$E$2:E13,E14)<99,"0",""))&COUNTIFS($D$2:D13,D14,$E$2:E13,E14)+IF(ROW()=2,0,1)

You can place the whole lot inside brackets and place it at the end of your current code to concatenate the other bits of the serial number.

Hope this helps.