vba文件对比并高亮显示

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

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 = 2 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 = 3
        
    Next
    
End Sub


Sub delRec()
    rw1 = ThisWorkbook.Sheets("MES1").Range("a65536").End(xlUp).Row
    For i = 2 To rw1
        If ThisWorkbook.Sheets("MES1").Range("A" & i).Interior.ColorIndex = 3 Then: ThisWorkbook.Sheets("MES1").Range("A" & i).EntireRow.Delete: End
    Next
End Sub

 

posted @ 2018-12-20 16:22  tec2019  阅读(542)  评论(0编辑  收藏  举报