不同表格查找重复数据VBA

分析两个表格中对应列的重复情况。

Sub Match_Dec()
    '两个表格,表格中的某一列为对应列,查找这两列中的重复记录和差异记录。
    
    Dim ar As Long, br As Long, i As Integer, j As Integer, num As Integer
        'ar/br为行数,i为外层循环数控制,j为内层循环数控制
    Dim A_Range As Range, B_Range As Range
    Dim myFont As Font
    
    Set A_Range = Worksheets("Sheet4").UsedRange
    Set B_Range = Worksheets("Sheet5").UsedRange
    
    ar = A_Range.Rows.Count
    br = B_Range.Rows.Count
    
    num = 0
'查找重复行
    
    For i = 1 To ar
        Debug.Print "第" & i; "行"
        For j = 1 To br
            If A_Range.Cells(i, 1) = B_Range.Cells(j, 1) Then
                Debug.Print "第" & j; "行为重复行"
'                'myRange.Cells(i, 1).EntireRow.Delete shift:=xlShiftUp 'xlShiftToLeft
'
                Set myFont = A_Range.Cells(i, 1).EntireRow.Font
                'Set myFont = B_Range.Cells(j, 1).EntireRow.Font
                With myFont
                .Name = "楷体"
                .Size = 15
                .Bold = True
        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值