第二天重置计数器

时间:2019-03-11 18:23:35

标签: excel vba counter userform

我必须创建一个表单,在该表单中需要放置一个输入计数器,该计数器必须在第二天重新启动,并且在表单关闭后不必重置。所发生的一切就是表格一直在计数,直到关闭为止。在我再次打开它之后,它从头开始。我希望在NumberBox上改变价值,直到第二天才重置。

这是我的代码

Set sf = ThisWorkbook.Sheets("CF")
Dim n As Long

Dim LDate As String
LDate = Format(Now, "yyyy/mm/dd hh:mm AM/PM")

n = sf.Range("A" & Application.Rows.Count).End(xlUp).Row



sf.Range("A" & n + 1).Value = Me.DateBox.Value
sf.Range("B" & n + 1).Value = Me.BatchNameBox.Value + "-" + NumberBox.Value

sf.Range("C" & n + 1).Value = Me.OperatorBox.Value
sf.Range("D" & n + 1).Value = Me.BatchVolBox.Value
sf.Range("E" & n + 1).Value = Me.APPAddedBox.Value
sf.Range("F" & n + 1).Value = Me.ZtagAddedBox.Value
sf.Range("G" & n + 1).Value = Me.StartTimeBox.Value
sf.Range("H" & n + 1).Value = Me.EndTimeBox.Value
sf.Range("I" & n + 1).Value = Me.ShootInvBox.Value
sf.Range("J" & n + 1).Value = Me.Vib1Box.Value
sf.Range("K" & n + 1).Value = Me.Vib2Box.Value
sf.Range("L" & n + 1).Value = Me.Vib3Box.Value
sf.Range("M" & n + 1).Value = Me.FlowBox.Value
sf.Range("N" & n + 1).Value = Me.CFPressureBox.Value
sf.Range("O" & n + 1).Value = Me.RecircTimeBox.Value
sf.Range("P" & n + 1).Value = Me.InitialBox.Value
sf.Range("Q" & n + 1).Value = Me.FinalBox.Value
sf.Range("R" & n + 1).Value = Me.RemovedBox.Value
sf.Range("S" & n + 1).Value = Me.CommentsBox.Value

Static cnt As Long
cnt = cnt + 1

Do While Me.BatchNameBox.Value > Me.BatchNameBox.Value
cnt = cnt + 1
Loop


If Me.BatchNameBox.Value > Me.BatchNameBox.Value Then
NumberBox.Value = 1
End If




NumberBox = Val(NumberBox) + 1
End Sub

Private Sub NumberBox_Change()

End Sub

Private Sub UserForm_Initialize()

Me.DateBox = Now()

代码结尾

0 个答案:

没有答案