簡體   English   中英

您如何比較兩個工作表中的列?

[英]How do you compare a column in two worksheets?

有人可以告訴我如何只比較一欄而不是整張紙嗎? 謝謝。

子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
Call compareSheets("Sofon", "Sofontest", "B1:B900")

End Sub


Sub compareSheets(Sofon As String, Sofontest As String, sRange as String)

Dim mycell As Range
Dim mydiffs As Integer

For Each mycell In ActiveWorkbook.Worksheets(Sofontest).sRange
    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


End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM