作为一项倡议,我目前正在开发一种替代的考勤监控系统。目前,我设计的用户表单如下所示: 时间戳用户表单
它是这样工作的:
员工将选择他/她将使用的时间戳类型:时间、超时、第一次休息开始、第一次休息结束、第二次休息开始或第二次休息结束。
然后在人员条码字段中输入人员编号。
目前,我有这个代码:
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub ClearButton_Click()
Call UserForm_Initialize
End Sub
Private Sub OKButton_Click()
Dim emptyRow As Long
'Make Sheet1 active
Sheet1.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1
'Transfer information
If TimeOptionButton1.Value = True Then
Cells(emptyRow, 5).Value = "Yes"
End If
If TimeOptionButton2.Value = True Then
Cells(emptyRow, 7).Value = "Yes"
End If
If BreakOptionButton1.Value = True Then
Cells(emptyRow, 9).Value = "Yes"
End If
If BreakOptionButton2.Value = True Then
Cells(emptyRow, 11).Value = "Yes"
End If
If BreakOptionButton3.Value = True Then
Cells(emptyRow, 14).Value = "Yes"
End If
If BreakOptionButton4.Value = True Then
Cells(emptyRow, 16).Value = "Yes"
End If
Cells(emptyRow, 2).Value = BarcodeTextBox.Value
End Sub
Private Sub UserForm_Initialize()
'Set Time In as default
TimeOptionButton1.Value = True
'Empty BarcodeTextBox
BarcodeTextBox.Value = ""
End Sub
我不是真正的 VBA 编码专家,我只是在网上搜索了代码。上面的代码确定了下一个将输入数据的空行。填写用户表单后,工作表中的结果如下所示: 结果
如您所见,在多行中输入了 1 名员工的时间戳。
但是,我想要的是只有 1 行将专用于一个员工编号,以便他/她的所有时间戳都在 1 行中,而不是在多行中。我希望有人可以帮助我。我想有一个代码,如果输入的人员条形码已经在工作表上,将被搜索,如果是,时间戳将输入同一行。我希望它位于 1 行,以便可以轻松制定公式,例如计算超支和人数。
非常感谢您的好心人!:)