简体   繁体   English

Excel序列号生成器; 顺序基于一年中的一周

[英]Excel serial number generator; sequential based on week of the year

I am attempting to generate 8 digit serial numbers with Excel based on the following: 我试图根据以下内容使用Excel生成8位数的序列号:

ABCDEFGH
  • A = Value in column C (User Specified) A = C列中的值(用户指定)
  • BC = YEAR (Which I have in hidden column) BC = YEAR(我在隐藏列中有)
  • D using = RIGHT(YEAR(A3), 2) where A3 is date entered. D using = RIGHT(YEAR(A3),2)其中A3是输入日期。
  • DE = Week in Year (Which I have in hidden column DE =年中的一周(我在隐藏的专栏中有
  • E using =WEEKNUM(A3). E使用= WEEKNUM(A3)。
  • FGH = Sequential numbers from 001 to 999. FGH =从001到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. 我希望每周的第一个序列号为001并运行到本周更改。 Serial number will then start over at 001 with the new week. 然后序列号将在新周开始于001。 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. 一旦我将日期放入A列,就会产生序列号(列F)。

Try this: 试试这个:

Get rank for the week number and add rownumber: G2=RANK(E2,$E$2:$E$5)+ROW() 获得周数的排名并添加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 排名,按周数分组: H2=SUMPRODUCT(($E$2:$E$5=E2)*($G$2:$G$5<G2))+1

Make 3 digit serial number: I2=RIGHT("000"&H2,3) 制作3位序列号: I2=RIGHT("000"&H2,3)

在此输入图像描述

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 要生成序列号的最后三位数,您可以使用以下内容(假设这是在G列,我将调用Seq No.,数据从第2行开始,我在G4中创建三位数序列

I am also assuming the year value is in column D and the week number is in column E. 我还假设年份值在D列,而周数在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) = 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. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM