Private TM As String 'time
Private N As Long '工号
Sub test()
Dim arr
Dim brr
Dim i As Long
Dim j As Long
Dim m As Long
Dim p As Long
Dim Q As Integer
N = Sheets("打卡").Range("E2")
Set d = CreateObject("Scripting.Dictionary")
Range("H2").FormulaR1C1 = "=TODAY()"
TM = Time
TD = Range("H2")
i = Sheets("工号查询").Cells(Rows.Count, 1).End(3).Row
arr = Sheets("工号查询").Cells(1, 1).Resize(i, 3)
For j = 2 To i
d(arr(j, 1)) = arr(j, 2)
Next
If Not d.Exists(N) Then
Sheets("打卡").Range("e2:f2").Clear
MsgBox "输入有误"
Exit Sub
End If
m = Sheets("打卡").Cells(Rows.Count, 1).End(3).Row
p = m
If Sheets("打卡").Cells(m, 1) = TD Then
Do Until Cells(p, 1) <>TD
p = p - 1
Loop
For j = m To p + 1 Step -1
If Cells(j, 2) = N Then
Cells(j, 5) = TM
Q = Q + 1
Sheets("打卡").Range("e2:f2").Clear
MsgBox "Bye"
End If
Next
If Q = 0 Then Call WRT
Else
Call WRT
End If
End Sub
Sub WRT()
Dim cR As Long
cR = Sheets("打卡").Cells(Rows.Count, 1).End(3).Row
Cells(cR + 1, 1) = TD
Cells(cR + 1, 2) = N
Cells(cR + 1, 4) = TM
Sheets("打卡").Range("e2:f2").Clear
MsgBox "早上好"
End Sub
按照正常的签到流程是:在一段时间内记录每个签到的人,并统一进行保存。(按照你的界面的意思来说)。如果是单纯的一个人过来打卡就马上进行保存的话,建议使用command控件。然后进行保存就可以了。
至于保存的代码是什么,我忘了,你可以百度一下open语句
open “c:\wode.txt” for output as #1
之类的语句。至于怎么写,可能会有人告诉你,我只告诉你思路。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)