如何比较两个工作表中的列?

时间:2015-12-03 09:15:26

标签: excel-vba vba excel

有人能告诉我如何只比较一列而不是整张表吗? 谢谢。

Sub Compare()

 Call compareSheets("Sofon", "Sofontest")

 End Sub


Sub compareSheets(Sofon As String, Sofontest As String)

Dim mycell As Range
Dim mydiffs As Integer

For Each mycell In ActiveWorkbook.Worksheets(Sofontest).UsedRange
    If Not mycell.Value = ActiveWorkbook.Worksheets(Sofon).Cells(mycell.Row, mycell.Column).Value Then

         mycell.Interior.Color = vbYellow
         mydiffs = mydiffs + 1

    End If
Next

MsgBox mydiffs & " differences found", vbInformation

ActiveWorkbook.Sheets(Sofontest).Select

End Sub

1 个答案:

答案 0 :(得分:0)

import sys   
sys.path.append("..")
import NEW2.test2