数字要增加,然后重新设置每个date

我在网上search了很多,这个论坛。 我发现了类似的问题,但没有回答我的问题。 我需要做的是,我需要生成一个数字,其中包含date,月份,然后序列号,需要重置每个新的date。 对于例如280901(28date09月01-序列号),280902,280903 …,然后290901下一个date,我是新的VB。 请帮忙!!

你可以使用公式来做到这一点。 如果你在列A中有你的date,并把这个公式在列B中创build序列号:

=TEXT(A1,"DDMM")&TEXT(COUNTIF($A$1:A1,A1),"0#") 

您将得到以下内容:

 28/09/2016 280901 28/09/2016 280902 28/09/2016 280903 28/09/2016 280904 29/09/2016 290901 29/09/2016 290902 29/09/2016 290903 29/09/2016 290904 

这不是一个免费的代码写作服务,但为了让你开始,你可以尝试下面的东西。

 Dim iVal As Integer, tdate As String, serial as String 'sets todays date as string tdate = Date 'counts how many serials there are for today and adds 1 iVal = Application.WorksheetFunction.CountIf(Range("A:A"), "*" & tdate & "*") + 1 'creates new serial serial = Date & " 000" & iVal 'just for this example it will put the new serial in column A Range("A" & iVal).Value = serial