zoukankan      html  css  js  c++  java
  • VBA实现表单自动编号

    效果:每次提交或刷新标段,表单案指定格式实现自动编号。如当天日期加数字编号的格式 即 2019年2月3日产生的第一张表单产生的编号格式为20190203-001 以此类推第二张表单编号为20190203-002 

    如果日期发生变化,那么日期后面的编号也从1开始。如2019年2月4日那么,他的编号20190204-001 如果是当天,他产生多章表单那么编号会自动递增。 如果表单编号所在单元格为空那么也将从001开始

    产生编号。

    代码:

    Sub autonum()
        a = Right([c2], 2)
        cdat = Format(Now(), "yyyymmdd")
        pc = Left([c2], 8)
        va = ThisWorkbook.Sheets("a3").Range("c2").Value
        MsgBox va
        With ThisWorkbook.Sheets("a3")
            If va = "" Or cdat <> pc Then
                c = Format(Now, "yyyy") & Format(Now, "mm") & Format(Now, "dd") & "-" & Format(1, "000")
                .Range("c2").Value = c
            Else
                c = Format(Now, "yyyy") & Format(Now, "mm") & Format(Now, "dd") & "-" & Format(a + 1, "000")
                .Range("c2").Value = c
            End If
        End With
    End Sub
    

      

  • 相关阅读:
    HDU 1423
    POJ 3264
    POJ 3177
    CodeForces 81A
    SPOJ RATING
    ZOJ 2588
    POJ 1523
    POJ 3667
    递归
    数据结构
  • 原文地址:https://www.cnblogs.com/luoye00/p/10469879.html
Copyright © 2011-2022 走看看