【问题标题】:How can I compare two columns with a range on excel?如何将两列与excel上的范围进行比较?
【发布时间】:2015-12-11 00:58:56
【问题描述】:

如何比较excel中的两列?考虑到我想比较几行,例如:A1-A10 与 B1-B-10 值比较

【问题讨论】:

  • 比较后你想做什么?
  • 突出差异

标签: excel excel-formula formula vba


【解决方案1】:

使用行差异。

Sub SelectDiffRws()
    Dim Rws As Long, Rng As Range, rng2 As Range, c As Range

    Rws = Cells(Rows.Count, "A").End(xlUp).Row
    Set Rng = Range(Cells(2, 1), Cells(Rws, 2))
    Set rng2 = Rng.RowDifferences(Range("A2"))

    Columns("A:B").Interior.Color = xlNone

    For Each c In rng2.Cells
        Range(Cells(c.Row, 1), Cells(c.Row, 2)).Interior.ColorIndex = 3
    Next c

End Sub

例如看这里 http://www.xlorate.com/vba-examples.html#Column%20Differences

请看这里的剪辑 https://youtu.be/Fcq4rgigu3w

sample workbook的可共享链接

【讨论】:

  • 谢谢,这很有用!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多