每月月底要和人事要离职人员名单,并账号列表里删除已经离职人员的账号,如下代码通过将账号列表与人事发来的离职清单进行对比,高亮找出离职人员的账号,并进行删除。

Sub DeleteMain()
Dim filenameobj As String
Dim wb As Workbook On Error Resume Next
Autoscreenupdating = False
ShowWindowInTaskbar = False
filenameobj = Application.GetOpenFilename("Excel Îļþ (*.xls),*.xls")
MsgBox filenameobj
Set wb = GetObject(filenameobj)
rw = wb.Sheets("Nov.").Range("a65536").End(xlUp).Row
'rw1 = ThisWorkbook.Sheets("MES1").Range("a65536").End(xlUp).Row
'MsgBox rw, wr1
For i = To rw jieguo = wb.Sheets("Nov.").Range("b" & i).Value
Set c = ThisWorkbook.Sheets("MES1").Range("a:a").Find(jieguo)
rn = c.Address
Range(rn).Interior.ColorIndex = xlNone
Range(rn).Interior.ColorIndex = Next End Sub Sub delRec()
rw1 = ThisWorkbook.Sheets("MES1").Range("a65536").End(xlUp).Row
For i = To rw1
If ThisWorkbook.Sheets("MES1").Range("A" & i).Interior.ColorIndex = Then: ThisWorkbook.Sheets("MES1").Range("A" & i).EntireRow.Delete: End
Next
End Sub
05-07 15:07