|
楼主 |
发表于 2020-10-1 01:18
|
显示全部楼层
代码:
- Private Function 生成编号() As String
- On Error Resume Next '
- Dim theYear$, theMonth$, theDay$
- Dim theCell As Range, theFirstAddress$, theStrMaxNumNow$, theStrNum$
- theYear = Year(Date): theMonth = Format(Month(Date), "00"): theDay = Format(Day(Date), "00")
- theStrNum = "GS" & theYear & theMonth & theDay
- theStrMaxNumNow = "00"
- With ThisWorkbook.Worksheets("汇总表").Columns(3)
- Set theCell = .Cells.Find(what:=theStrNum, after:=.Cells(.Count), LookIn:=xlValues, LookAt:= _
- xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
- , MatchByte:=False, SearchFormat:=False)
- If Not theCell Is Nothing Then
- theFirstAddress = theCell.Address
- Do
- If Right(theCell, 3) > theStrMaxNumNow Then theStrMaxNumNow = Right(theCell, 2)
- Set theCell = .FindNext(theCell)
- Loop Until theCell.Address = theFirstAddress
- End If
- End With
- 生成编号 = "GS" & theYear & theMonth & theDay & Format(CVar(theStrMaxNumNow) + 1, "00")
- End Function
复制代码
一些小问题有解答,锻炼身体爬下楼
|
评分
-
1
查看全部评分
-
|