【发布时间】:2017-11-06 18:41:24
【问题描述】:
请协助修改以下代码。我想做的是根据每个员工的招聘日期为每个员工创建唯一的序列号,例如。 on 于 2016 年 1 月 13 日被录用,序列号带有最后两个数字(年、月、日+00),这意味着(16011300)表示同一天录用的人和(年、月、日) +01) 表示 (16011301) 表示同一天雇用的第二个。并为在不同日子雇用的人做同样的事情。首先看下面的图片代码做什么,但第二个是我想要的。提前感谢您的帮助 使用的代码:
Dim myDate As Date, i As Long, dayPart As String
Application.EnableEvents = False
For i = 2 To Rows.Count
If Cells(i, 5).Value > 1 And Not IsEmpty(Cells(i, 5).Value) Then
myDate = Cells(i, 5)
dayPart = Format(Year(myDate), "00") - 2000 & _
Format(Month(myDate), "00") & _
Format(Day(myDate), "00") & 1
Cells(i, 2) = dayPart
End If
Next i
Application.EnableEvents = True
【问题讨论】: