码迷,mamicode.com
首页 > 其他好文 > 详细

EXCEL跨表比较两列,并填充新值背景

时间:2016-06-03 14:35:38      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

Sub FillNewToYellow()
    Dim dic
    Dim oldArr(), updatedArr()
  
    On Error Resume Next
    If Worksheets("old") Is Nothing Then
        MsgBox "Missing old sheet"
    ElseIf Worksheets("updated") Is Nothing Then
        MsgBox "Missing updated sheet"
    Else
        Set dic = CreateObject("Scripting.Dictionary")
        ActiveWorkbook.Sheets("old").Activate
        oldArr = Range("B1:B" & ActiveSheet.UsedRange.Rows.Count)
        
        For i = 1 To UBound(oldArr)
            dic(oldArr(i, 1)) = ""
        Next
        
        ActiveWorkbook.Sheets("updated").Activate
        updatedArr = Range("B1:B" & ActiveSheet.UsedRange.Rows.Count)
        
        For i = 1 To UBound(updatedArr)
            If dic.exists(updatedArr(i, 1)) = False Then
                Rows(i & ":" & i).Select
                With Selection.Interior
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .Color = 65535 ‘Yellow
                    .TintAndShade = 0
                    .PatternTintAndShade = 0
                End With
            End If
        Next
    End If
End Sub

  

EXCEL跨表比较两列,并填充新值背景

标签:

原文地址:http://www.cnblogs.com/yipeng-yu/p/5556072.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!