Selenium C# – Compare two excel sheets in Visual Studio

Hi,

I  have a requirement to compare tow excel sheets using VS C#. Are there any ways to implement so I can compare two excel sheets and third sheet showing pass/fail.

If anyone suggest how to create it. that would be great.

Default Asked on January 21, 2019 in Selenium WebDriver.

use below VB macro to compare two excel sheets.

Sub Compare()
Call compareSheets(“Sheet1”, “Sheet2”)
End Sub
Sub compareSheets(shtSheet1 As String, shtSheet2 As String)
Dim mycell As Range
Dim mydiffs As Integer
‘For each cell in sheet2 that is not the same in Sheet1, color it yellow
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 = vbYellow
        mydiffs = mydiffs + 1
    End If
Next
‘Display a message box to demonstrate the differences
MsgBox mydiffs & ” differences found”, vbInformation
ActiveWorkbook.Sheets(shtSheet2).Select
End Sub
on February 19, 2019.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.