Compare two reports in Excel to check whether the data is the same

Hi, I would like to compare two reports in Excel to check whether the data is the same and, if not, to correct the data in one of these reports. Do you have an idea how to go about it?

Hi @sullivanne

Check this:

1 Like

Hi @sullivanne

Your query is quite confusing could you be more specific. If your data is not confidential then better to share the input and required output data files.

Hope you understand!!

@sullivanne

  1. Read the Excel Files:

Excel Application Scope (File Path: excelPath1)
Read Range (Output: dtReport1, Sheet Name: “Sheet1”)

Excel Application Scope (File Path: excelPath2)
Read Range (Output: dtReport2, Sheet Name: “Sheet1”)

  1. Compare and Correct the Data:

For Each row in dtReport1
Assign index = dtReport1.Rows.IndexOf(row)
For Each column in dtReport1.Columns
If dtReport1.Rows(index)(column).ToString() <> dtReport2.Rows(index)(column).ToString()
Assign dtReport2.Rows(index)(column) = dtReport1.Rows(index)(column)
3. Write the Corrected Data Back to Excel:

Excel Application Scope (File Path: excelPath2)
Write Range (DataTable: dtReport2, Sheet Name: “Sheet1”, Starting Cell: “A1”)