数据加载中……
VBA编写 考勤分析宏程序

为公司编写的一个宏程序,班次太多还没完成

Sub kqfx()
'取得打卡表的记录行数
kqcount = Sheet1.UsedRange.Rows.Count


'取得排班表的记录行数
pbcount = Sheet3.UsedRange.Rows.Count


For i = 2 To pbcount
   Sheet2.Cells(i, 
1= Sheet3.Cells(i, 1)
   Sheet2.Cells(i, 
2= CStr(Sheet3.Cells(i, 2))
   Sheet2.Cells(i, 
2).NumberFormat = "@"
   Sheet2.Cells(i, 
3= Sheet3.Cells(i, 3)
   Sheet2.Cells(i, 
4= Sheet3.Cells(i, 4)
   Sheet2.Cells(i, 
5= Sheet3.Cells(i, 5)

Next i
'创建汇总表完成

For i = 2 To pbcount
    y 
= 1 '打卡计数
    For j = 2 To kqcount
        
        
If Sheet2.Cells(i, 2= Sheet1.Cells(j, 1Then '相同员工
        
              
' cfjl = Sheet1.Cells(j, 6) 排除重复打卡记录 后续考虑
           
               
If Sheet1.Cells(j, 6<> "重复记录" Then
                   
                   Sheet2.Cells(i, y 
+ 9= Sheet1.Cells(j, 3'考勤时间行改成列
                   
                   y 
= y + 1
                   
               
End If
     
      
        
End If

   
Next j
   
Next i

'记录汇总完毕 开始分析

For i = 2 To pbcount



 
   flag 
= ""
   banci 
= Sheet2.Cells(i, 5)
   jb1 
= ""
   jb2 
= ""
   lbsj 
= 0
   Overtimes 
= 0
    
If IsEmpty(Sheet2.Cells(i, 10)) Or IsEmpty(Sheet2.Cells(i, 11)) Or IsEmpty(Sheet2.Cells(i, 12)) Or IsEmpty(Sheet2.Cells(i, 13)) Then
    
      flag 
= flag + "考勤记录不完整"
      
      Sheet2.Cells(i, 
9= flag
    end if

posted on 2010-06-20 08:44 seaship 阅读(454) 评论(0)  编辑 收藏 引用