我有这个宏,它可以比较两张相互作用的两个范围。 每周都会提供此工作表的新版本,我想将其与最新版本进行比较。所以现在我将Sofon2与Sofon(New vs Old)进行比较。 我的想法是在另一张表格中填写A1中旧表格的名称,并在B1中填写新表格的名称。有谁知道如何做或有更好的解决方案? 谢谢
Sub Compare()
Call compareSheets("Sofon", "Sofon2")
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).range("M:M")
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 in Column M (Salesman)", vbInformation
ActiveWorkbook.Sheets(Sofontest).Select
End Sub