我有一个用户窗体,其中包含用于输入数据的多个文本框。该用户窗体有一个保存按钮,用于将输入存储到数据表中。为了清楚起见,请参考以下内容:
机器1-早上报废:____ kg晚上报废:____ kg。
有更多的机器,但布局如前所述。代码工作正常。
但是,我需要通过添加以下废料类型来改善数据:
1号机-早晨报废:干:___ kg湿:___ kg。与夜间报废相同。 Userform structure
If Chain1_morning.Value >= 0 Then
Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1).Value = DateValue(Datebox.Value)
Cells(WorksheetFunction.CountA(Range("F:F")) + 1, 6).Value = "CHAIN 1"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 1).Value = "DRY"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 2).Value = "Morning"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 3).Value = Chain1_morning.Value
Cells(WorksheetFunction.CountA(Range("J:J")) + 1, 10).Value = "PRODUCTION"
ElseIf Chain1_morning.Value = " " Then
End If
If Chain1_morning_Wet.Value >= 0 Then
Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1).Value = DateValue(Datebox.Value)
Cells(WorksheetFunction.CountA(Range("F:F")) + 1, 6).Value = "CHAIN 1"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 1).Value = "WET"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 2).Value = "Morning"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 3).Value = Chain1_morning_Wet.Value
Cells(WorksheetFunction.CountA(Range("J:J")) + 1, 10).Value = "PRODUCTION"
ElseIf Chain1_morning_Wet.Value = " " Then
End If
If Chain1_Afternoon.Value >= 0 Then
Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1).Value = DateValue(Datebox.Value)
Cells(WorksheetFunction.CountA(Range("F:F")) + 1, 6).Value = "CHAIN 1"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 3).Value = Chain1_Afternoon.Value
Cells(WorksheetFunction.CountA(Range("I:I")) + 1, 10).Value = "PRODUCTION"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 2).Value = "Afternoon"
ElseIf Chain1_Afternoon.Value = " " Then
End If
If Chain1_Night.Value >= 0 Then
Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1).Value = DateValue(Datebox.Value)
Cells(WorksheetFunction.CountA(Range("F:F")) + 1, 6).Value = "CHAIN 1"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 1).Value = "DRY"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 2).Value = "Night"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 3).Value = Chain1_Night.Value
Cells(WorksheetFunction.CountA(Range("J:J")) + 1, 10).Value = "PRODUCTION"
ElseIf Chain1_Night.Value = " " Then
End If
If Chain1_Night_Wet.Value >= 0 Then
Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1).Value = DateValue(Datebox.Value)
Cells(WorksheetFunction.CountA(Range("F:F")) + 1, 6).Value = "CHAIN 1"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 1).Value = "WET"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 2).Value = "Night"
Range("A2").End(xlDown).End(xlToRight).Offset(0, 3).Value = Chain1_Night_Wet.Value
Cells(WorksheetFunction.CountA(Range("J:J")) + 1, 10).Value = "PRODUCTION"
ElseIf Chain1_Night_Wet.Value = " " Then
End If
然后,在我修改了这些代码之后,即使我没有输入任何内容,该程序仍保存到数据表中。 Datasheet look after click "Save" on userform.
有什么办法可以纠正这个问题?如果您需要,我很乐意提供更多信息。
P / s:Chain1_Afternoon中的代码是原始代码结构。 P / s / s:我只修改了Chain 1中的代码。另一台机器的代码仍然保持不变。