我在比較2個工作簿中的數據,列標題的順序相同,它們是:ID,DepartmentName,Name,SalesAmount,StartDate,End Date。比較2個excel工作簿中的數據(未排序的數據)
當前我正在比較工作表1中的所有單元格到工作表2(例如:工作表1中的單元格A1到工作表2中的單元格A1)。但是,現在工作表2中的數據採用了不同的順序,因此我目前的比較方法不起作用。
如果工作表1包含正確的數據,我希望能夠將正確的行匹配到工作表2並檢查數據是否匹配。對於表2中不存在的行,會顯示一張表來通知我缺少哪些ID。與之相比細胞與細胞和
代碼標識的差異:
For Each mycell In ActiveWorkbook.Worksheets(shtSheet2).UsedRange
If Not mycell.Value = ActiveWorkbook.Worksheets(shtSheet1).Cells(mycell.Row, mycell.Column).Value Then
mycell.Interior.Color = vbRed
difference = difference + 1
End If
Next
任何建議或幫助將不勝感激!謝謝
您需要展示迄今爲止所做的工作。 – ChipsLetten
@ChipsLetten我已經添加了我的代碼到目前爲止 – Tony
你可以在進行匹配之前用相同的標準對兩張紙進行排序嗎? –